(function($) {
	var doOneCmdList = function(sandbox, CmdId, CmdList, inObj, publicCmdId, noRefreshinCircle) {
		publicCmdId = publicCmdId || "";
		if (!CmdList) {
			$PublicFun.err("doOneCmdList", "命令集错误或不存在 ID:" + CmdId);
			return false;
		}
		if (!inObj) // 用于框架数据刷新，非输入变量
			inObj = {};
		sandbox.refreshQueue = inObj;
		
		var iCount = CmdList.length, start = Date.now();
		$PublicFun.logGrp("CmdIn", CmdId + "   Count:" + iCount);
		var mLastWhere;
		for (var i = 0; i < iCount; i++) {
			var mTmpOne = CmdList[i];
			var mLog = CmdId + " Cmd:" + i + "  "; 
			if (mTmpOne.B == 1) {
				$PublicFun.log("BeginCmd", mLog + " Filter:" + JSON.stringify(mTmpOne.W) + " Content:" + JSON.stringify(mTmpOne.C) + " Flag:" + mTmpOne.F);
				//$PublicFun.log("BeginCmd", mLog + " Filter:" + JSON.stringify(mTmpOne.W) + " Flag:" + mTmpOne.F, mTmpOne.C);
				if (mTmpOne.W == "#P") {
					if (!mLastWhere) {
						$PublicFun.log("EndCmd", mLog + " Filer:#P" + " :" + mLastWhere);
						continue;
					}
				} else {
					var mTmpExp = $DynFun.replaceVarValue(sandbox, mTmpOne.RL, mTmpOne.W, 1);
					var mFilterValue = sandbox.evalValue(mTmpExp);
					mLastWhere = mFilterValue;
					if (! mFilterValue) {
						$PublicFun.log("EndCmd", mLog + " Filer:" + mTmpExp + " :" + mFilterValue);
						continue;
					}
				}
			} else {
				$PublicFun.log("BeginCmd", mLog + " Content:" + JSON.stringify(mTmpOne.C) + " Flag:" + mTmpOne.F);
				//$PublicFun.log("BeginCmd", mLog + " Flag:" + mTmpOne.F, mTmpOne.C);
			}
			var iResult = 1;
			switch (mTmpOne.F) {
			case 1: // >9999900;
				doOneOther(sandbox, mTmpOne, inObj, mLog, publicCmdId);
				iResult = 1;
				break;
			case 2:
				doServerCmd(sandbox, mTmpOne, inObj, mLog, publicCmdId);
				iResult = 1;
				break;
			default:
				iResult = doOneCmd(sandbox, mTmpOne, inObj, mLog);
				break;
			}
			if (iResult < 0) {
				// $PublicFun.log("EndCmd", "End Cmd By Index:" + i);
				break;
			}
		}
		$PublicFun.log('CmdOut', CmdId + ' [耗时：' + (Date.now() - start) + '\'ms]');
		$PublicFun.logGrpEnd();
		if (sandbox.$callback != undefined) {
			// Fixed by kevin, send runtime into callback
			if (! noRefreshinCircle){
				// console.log('refresh bind property:', inObj)
				sandbox.$callback(inObj, sandbox.$runtime);
				//$PublicFun.log("Callback End", CmdId);
			}
		}
	},
	
	doOneCmd = function(sandbox, oneCmd, RefreshObj, logHead) {
		// { Type : 8, Flag : 0, Filter : "", Content : "###1[temp.Testvalue2]+[temp.Testvalue3]",}
		switch (oneCmd.T) {
		case 0: // 公式运算
		case 8: // 公式运算
			return doType8(sandbox, oneCmd, RefreshObj, logHead);
		case 3: // 脚本运行
			return doType3(sandbox, oneCmd, RefreshObj, logHead);
		case 35:// 操作动态表
			return doType35(sandbox, oneCmd, RefreshObj, logHead);
		case 1:// 其它数据库命令
			return doType1(sandbox, oneCmd, RefreshObj, logHead);
		case 5: // HTTP 操作
			return doType5(sandbox, oneCmd, RefreshObj, logHead);
		case 7: // Com Lib
			return doType7(sandbox, oneCmd, RefreshObj, logHead);
		case 6: // FLEX CALL
			return doType6(sandbox, oneCmd, RefreshObj, logHead);
		case 4: // 弹出Windows
			return doType4(sandbox, oneCmd, RefreshObj, logHead);
		case 28: // 转IVR
			break;
		default:
			break;
		}
	},


	/**
	 * @method setReturnValue
	 * @description 设置返回值，返回-1，结束当前命令运行
	 */

	setReturnValue = function(sandbox, oneCmd, ReturnObj, RefreshObj, logHead) {
		if (ReturnObj == "STOP-RUN-NEXT-COMMAND") {
			$PublicFun.log("EndCmd", logHead + " STOP-RUN-NEXT-COMMAND");
			return -1; //
		}
		
		if (ReturnObj instanceof Array) {
			setArrayValue(sandbox, oneCmd, ReturnObj, RefreshObj, logHead);
		} else {
			setValueString(sandbox, oneCmd, ReturnObj, RefreshObj, logHead);
		}
		return 1;
	},
	/**
	 * @method setReturnValue Mulit SelectSql
	 * @description 设置返回值，返回-1，结束当前命令运行
	 */

	setReturnValueMSelect = function(sandbox, oneCmd, ReturnObj, RefreshObj, logHead) {
		if (ReturnObj instanceof Array) {
			var RLen = ReturnObj.length;
			var mReturnVariant = oneCmd.RT;
			if (mReturnVariant == undefined) {
				$PublicFun.log("EndCmd", logHead + "  (无返回接收)");
				return 1;
			}
			var iCount = mReturnVariant.length, receivers = [];
			// PID->PN 由ID变为变量名, RIndex->RI , RType->RT
			for (var i = 0; i < iCount; i++) {
				var mOne = mReturnVariant[i];
				receivers.push(mOne.PN);

				if (mOne.RT == 0) {
					var mTmp = sandbox.getOneVarStruct(mOne.PN)
					if (mTmp != undefined) {
						if (mOne.RI > 0) {
							if (mOne.RI <= RLen) {
								var mTmpOneRs = ReturnObj[mOne.RI - 1];
								if (mTmpOneRs.count > -1) {
									RefreshObj[mOne.PN] = $DynFun.refreshObjNew($DynFun.setSystemVar(sandbox, mTmp, mTmpOneRs.fields));
								} else {
									RefreshObj[mOne.PN] = $DynFun.refreshObjNew($DynFun.setSystemVar(sandbox, mTmp, []));
								}
							} else {
								$PublicFun.log("setReturnValueMSelect", "返回次序超出结果集范围 ：" + mOne.RI);
								RefreshObj[mOne.PN] = $DynFun.refreshObjNew($DynFun.setSystemVar(sandbox, mTmp, []));
							}
						} else {
							$PublicFun.log("setReturnValueMSelect", "返回次序不正确 ：" + mOne.RI);
							RefreshObj[mOne.PN] = $DynFun.refreshObjNew($DynFun.setSystemVar(sandbox, mTmp, []));
						}
					}
				} else {
					if (mOne.RI > 0) {
						if (mOne.RI <= RLen) {
							var mTmpOneRs = ReturnObj[mOne.RI - 1];
							if (mTmpOneRs.count > -1) {
								$DynFun.setLocateVar(sandbox, mOne.PN, mTmpOneRs.fields);
							} else {
								$DynFun.setLocateVar(sandbox, mOne.PN, []);
							}
						} else {
							$PublicFun.log("setReturnValueMSelect", "返回次序超出结果集范围 ：" + mOne.RI);
							$DynFun.setLocateVar(sandbox, mOne.PN, []);
						}
					} else {
						$PublicFun.log("setReturnValueMSelect", "返回次序超出结果集范围 ：" + mOne.RI);
						$DynFun.setLocateVar(sandbox, mOne.PN, []);
					}
				}
			}
			$PublicFun.log("EndCmd", logHead + "[" + receivers.join(',') + "]");
		} else {
			$PublicFun.err("setReturnValueMSelect", "非法的多SQL返回结果集");
		}
		return 1;
	},
	/**
	 * @method SetArrayData
	 * @description 设置数组信息
	 */
	setArrayValue = function(sandbox, oneCmd, value, RefreshObj, logHead) {
		var mReturnObj = oneCmd.RT;
		if (mReturnObj == undefined) {
			_displayResult('EndCmd', logHead + '[无接收]', value);
			return 1;
		}
		var iCount = mReturnObj.length;
		var mSub = value[0];
		var mSubLen;
		if (!(mSub instanceof Array)) {
			mSubLen = -1;
		} else {
			mSubLen = mSub.length;
		}
		var RLen = value.length, receivers = [], orders = [];
		// PID->PN 由ID变为变量名, RIndex->RI , RType->RT
		var setCount=0;
		for (var i = 0; i < iCount; i++) {
			var mOne = mReturnObj[i];
			if (mOne.RI > 0)
				orders[mOne.RI - 1] = mOne.PN;
			else
				receivers.push(mOne.PN);

			if (mOne.RT == 0) {
				var mTmp = sandbox.getOneVarStruct(mOne.PN);
				if (mTmp != undefined) {
					if (mOne.RI > 0) {
						if (mSubLen > -1) {
							if (mOne.RI <= mSubLen) {
								RefreshObj[mOne.PN] = $DynFun.refreshObjNew($DynFun.setSystemVar(sandbox, mTmp, mSub[mOne.RI - 1]));
							} else {
								RefreshObj[mOne.PN] = $DynFun.refreshObjNew($DynFun.setSystemVar(sandbox, mTmp, ""));
							}
						} else {
							if (mOne.RI <= RLen) {
								RefreshObj[mOne.PN] = $DynFun.refreshObjNew($DynFun.setSystemVar(sandbox, mTmp, value[mOne.RI - 1]));
							} else {
								RefreshObj[mOne.PN] = $DynFun.refreshObjNew($DynFun.setSystemVar(sandbox, mTmp, ""));
							}
						}
					} else {
						if (setCount==0){
							setCount=1;
							RefreshObj[mOne.PN] = $DynFun.refreshObjNew($DynFun.setSystemVar(sandbox, mTmp, value));
						}else
							RefreshObj[mOne.PN] = $DynFun.refreshObjNew($DynFun.setSystemVar(sandbox, mTmp,$.extend(true, [], value)));
					}
				}
			} else {
				if (mOne.RI > 0) {
					if (mSubLen > -1) {
						if (mOne.RI <= mSubLen) {
							$DynFun.setLocateVar(sandbox, mOne.PN, mSub[mOne.RI - 1]);
						} else {
							$DynFun.setLocateVar(sandbox, mOne.PN, "");
						}
					} else {
						if (mOne.RI <= RLen) {
							$DynFun.setLocateVar(sandbox, mOne.PN, value[mOne.RI - 1]);
						} else {
							$DynFun.setLocateVar(sandbox, mOne.PN, "");
						}
					}
				} else {
					if (setCount==0){
						setCount=1;
						$DynFun.setLocateVar(sandbox, mOne.PN, value);
					}else
						$DynFun.setLocateVar(sandbox, mOne.PN, $.extend(true, [], value));
				}
			}
		}
		
		var str = '';
		if (orders.length > 0)
			str += '[' + orders.join(',') + ']';
		if (receivers.length > 0)
			str += '[' + receivers.join(',') + ']';
		_displayResult('EndCmd', logHead + str, value);
	},

	/**
	 * @method setValueString
	 * @description 设置单值信息
	 */
	setValueString = function(sandbox, oneCmd, value, RefreshObj, logHead) {
		var mReturnObj = oneCmd.RT;
		if (mReturnObj == undefined) {
			_displayResult('EndCmd', logHead + '[无接收]', value);
			return 1;
		}
		// console.log(value);

		var iCount = mReturnObj.length, receivers = [];
		// PID->PN 由ID变为变量名, RIndex->RI , RType->RT
		for (var i = 0; i < iCount; i++) {
			var mOne = mReturnObj[i];
			receivers.push(mOne.PN);
			if (mOne.RT == 0) {
				var mTmp = sandbox.getOneVarStruct(mOne.PN);
				if (mTmp != undefined) {
					if (mOne.RI > 1) {
						var a = $DynFun.refreshObjNew($DynFun.setSystemVar(sandbox, mTmp, ""));
						RefreshObj[mOne.PN] = a;
					} else {
						var a = $DynFun.refreshObjNew($DynFun.setSystemVar(sandbox, mTmp, value));
						RefreshObj[mOne.PN] = a;
					}

				} else {
					$PublicFun.err("setValueString", logHead + " 变量不存在: " + mOne.PN);
				}
			} else {
				if (mOne.RI > 1) {
					$DynFun.setLocateVar(sandbox, mOne.PN, "");
				} else {
					$DynFun.setLocateVar(sandbox, mOne.PN, value);
				}
			}
		}
		_displayResult('EndCmd', logHead + "[" + receivers.join(',') + "]", value);
	},
	
	_displayResult = function(head, log, value) {
		if (value == undefined)
			$PublicFun.log(head, log);
		else if (typeof(value) == 'string')
			$PublicFun.log(head, log + ' ← ' + (value == ''?'\'\'':value));
		else if (typeof(value) == 'boolean')
			$PublicFun.log(head, log + ' ← ' + value);
		else if (typeof(value) == 'number')
			$PublicFun.log(head, log + ' ← ' + value);
		else if ($.type(value) == 'array')
			$PublicFun.log(head, log + ' ← Array[' + value.length + ']', {'Array' : value});
		else
			$PublicFun.log(head, log + ' ← ', value);
	},
	
	doType7_15 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		if (mArr.length > 2) {
			var mURL = mArr[0];
			var mTitle = mArr[1];
			var mPara = mArr[2];
			mArr = $PublicFun.stringToArray(mPara, "**");
			if (mArr.length != 10) {
				$PublicFun.err("Show Pop IE", "显示IE参数传入错误:" + vParameter);
				return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			}
			var mShowIEPara = "height=" + $PublicFun.stringToInt(mArr[0]) + ", width=" + $PublicFun.stringToInt(mArr[1]);
			var mTmp = $PublicFun.stringToInt(mArr[2]);
			mShowIEPara += ",top=" + mTmp;
			mTmp = $PublicFun.stringToInt(mArr[3]);
			mShowIEPara += ",left=" + mTmp;
			mTmp = $PublicFun.stringToInt(mArr[4]);
			if (mTmp == 0) {
				mShowIEPara += ",toolbar =no";
			} else {
				mShowIEPara += ",toolbar =yes";
			}
			mTmp = $PublicFun.stringToInt(mArr[5]);
			if (mTmp == 0) {
				mShowIEPara += ",menubar =no";
			} else {
				mShowIEPara += ",menubar =yes";
			}
			mTmp = $PublicFun.stringToInt(mArr[6]);
			if (mTmp == 0) {
				mShowIEPara += ",scrollbars =no";
			} else {
				mShowIEPara += ",scrollbars =yes";
			}
			mTmp = $PublicFun.stringToInt(mArr[7]);
			if (mTmp == 0) {
				mShowIEPara += ",resizable =no";
			} else {
				mShowIEPara += ",resizable =yes";
			}
			mTmp = $PublicFun.stringToInt(mArr[8]);
			if (mTmp == 0) {
				mShowIEPara += ",location =no";
			} else {
				mShowIEPara += ",location =yes";
			}
			mTmp = $PublicFun.stringToInt(mArr[9]);
			if (mTmp == 0) {
				mShowIEPara += ",status =no";
			} else {
				mShowIEPara += ",status =yes";
			}
			return setReturnValue(sandbox, oneCmd, $PublicFun.openWindowsNewOtherURL(mURL, mTitle, mShowIEPara), RefreshObj, logHead);
		} else {
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
	},

	doType7_4_sub = function(sandbox, otherFieldValue, sendKey, docType, status, tryCount, docPath, comment, vTo, vTo2, vTo3, vFromStr, vBeginTime, OtherSub) {
		var otherF = "", otherV = "";
		if (otherFieldValue) {
			var mTmpArr = $PublicFun.stringToArray(otherFieldValue, "|*|");
			var iTmpCount = mTmpArr.length;
			for (var i = 0; i < iTmpCount; i++) {
				var iTmpIndex = mTmpArr[i].indexOf("=");
				if (iTmpIndex > -1) {
					otherF += "," + mTmpArr[i].substring(0, iTmpIndex);
					otherV += ",'" + mTmpArr[i].substring(iTmpIndex + 1).replace2("'", "''") + "'";
				}
			}
		}
		var mPara = {};
		mPara["C1"] = otherF;
		mPara["C2"] = sendKey;
		mPara["C3"] = docType;
		mPara["C4"] = status;
		mPara["C5"] = tryCount;
		mPara["C6"] = docPath;
		mPara["C7"] = comment;
		mPara["C8"] = vTo;
		mPara["C9"] = vTo2;
		mPara["C10"] = vTo3;
		mPara["C11"] = vFromStr;
		if ($PublicFun.isDate(vBeginTime)) {
			mPara["C12"] = vBeginTime;
		} else {
			mPara["C12"] = sandbox.getdbtime();
		}
		mPara["C13"] = otherV;

		var sqlsInfo = [];
		sqlsInfo.push({
			key : "DynBD.Exec.SendMail",
			params : mPara
		});
		if (OtherSub) {
			var iCount = OtherSub.length;
			for (var i = 0; i < iCount; i++) {
				sqlsInfo.push({
					key : "DynBD.Exec.SendSub",
					params : {
						C1 : sendKey,
						C2 : i,
						C3 : OtherSub[i]
					}
				});
			}
		}
		var mRs = $F.ajaxSync("SystemDo1", {
			token : sandbox.$token,
			dbPool : "",
			sqls : sqlsInfo
		}, sandbox.$digest);
		if (mRs) {
			if (mRs.code > 0) {
				return mRs.code;
			} else {
				$PublicFun.err("Send Email/Fax/SMS", "插入数据失败");
				return -1;
			}

		} else {
			$PublicFun.err("Send Email/Fax/SMS", "插入数据失败");
			return -1;
		}
	},

	doType7_DoCallBackCmd = function(sandbox, callbackCmd, code, data, msg) {
		sandbox.R["CODE"] = code;
		sandbox.R["RESULT"] = data;
		sandbox.R["MESSAGE"] = msg;
		var CmdList = sandbox.$dynCmds["P" + callbackCmd];
		if (CmdList) {
			doOneCmdList(sandbox, callbackCmd, CmdList);
		} else {
			$PublicFun.err("doType7_DoCallBackCmd", "配置的回调命令不存在 CmdId:" + callbackCmd);
		}
	},

	doType7_1 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mSourceFile = "", mTargetFile = "", mCallbackCmd = "";
		if (mArr.length > 0) {
			mSourceFile = mArr[0];
		}
		if (mArr.length > 1) {
			mTargetFile = mArr[1];
		}
		if (mArr.length > 2) {
			mCallbackCmd = mArr[2];
		}
		if (mSourceFile.trim() == "") {
			$PublicFun.err("MergeFile", "源文件名为空");
			doType7_DoCallBackCmd(sandbox, mCallbackCmd, -1, "", "源文件名为空");
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
		if (mTargetFile.trim() == "") {
			$PublicFun.err("MergeFile", "目标文件名为空");
			doType7_DoCallBackCmd(sandbox, mCallbackCmd, -1, "", "目标文件名为空");
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
		var mBuildData = doType7_BuildMergeValue(sandbox);
		var mWpsFlag = $PublicFun.stringToInt($PublicFun.getPara(sandbox, "WPSFLG")); // sandbox.$instance.project.getParam("WPSFLG"));
		var data = {
			"op" : "Merage",
			"var" : mBuildData,
			"fileName" : mSourceFile,
			"targetName" : mTargetFile,
			"wps" : mWpsFlag
		};
		doType7_Send(data, mCallbackCmd, sandbox, oneCmd, logHead, 1);
	},

	doType7_2 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mAddress = "", mTitle = "", mContent = "", mAllFiles = "", mShowMerge = 0, mOtherValue = "", mBeginTime = "", mCallbackCmd = "";
		if (mArr.length > 0) {
			mAddress = mArr[0];
		}
		if (mArr.length > 1) {
			mTitle = mArr[1];
		}
		if (mArr.length > 2) {
			mContent = mArr[2];
		}
		if (mArr.length > 3) {
			mAllFiles = mArr[3];
		}
		if (mArr.length > 4) {
			mShowMerge = $PublicFun.stringToInt(mArr[4]);
		}
		if (mArr.length > 5) {
			mOtherValue = mArr[5];
		}
		if (mArr.length > 6) {
			mBeginTime = mArr[6];
		}
		if (mArr.length > 7) {
			mCallbackCmd = mArr[7];
		}
		var mCallBackData = {};
		mCallBackData["cbCmd"] = mCallbackCmd;
		mCallBackData["addr"] = mAddress;
		mCallBackData["title"] = mTitle;
		mCallBackData["bd"] = mBeginTime;
		mCallBackData["other"] = mOtherValue;

		var iIndex = mAllFiles.indexOf("#*#");
		var mLocateFile = "", mTemplateFile = "";
		if (iIndex > -1) {
			mLocateFile = mAllFiles.substr(0, iIndex);
			mTemplateFile = mAllFiles.substr(iIndex + 3);
		} else {
			mLocateFile = mAllFiles;
			mTemplateFile = "";
		}
		var eMailInfo = new $PublicFun.$ADVLIB.EMAIL();
		if (eMailInfo.addAttatchFile(sandbox, mLocateFile, mTemplateFile) < 0) {
			$PublicFun.err("doType7_2", "发送EMAIL 文件处理失败");
			// 失败;
			doType7_DoCallBackCmd(sandbox, mCallbackCmd, -1, "", "发送EMAIL，附件处理失败");
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
		var mMergeFlag = 0;
		if (mContent.substr(0, 5).toUpperCase() == "#FILE") {
			mMergeFlag = 1;
		}
		if (mMergeFlag == 0) {
			if (eMailInfo.docMergeList > "" || eMailInfo.MergeList > "") {
				mMergeFlag = 1;
			}
		}
		var mMergeData = "";
		if (mMergeFlag == 1) {
			mMergeData = doType7_BuildMergeValue(sandbox);
		}
		var mDownLoadFlag = $PublicFun.stringToInt($PublicFun.getPara(sandbox, "FMODE"));// sandbox.$instance.project.getParam("FMODE"));
		var mDowLoadServer = $PublicFun.getPara(sandbox, "FTPOUT");// sandbox.$instance.project.getParam("FTPOUT");
		if (mDowLoadServer == undefined) {
			mDowLoadServer = "";
		}
		var mDowLoadServer1 = $PublicFun.getPara(sandbox, "FTPOUE");// sandbox.$instance.project.getParam("FTPOUE");
		if (mDowLoadServer1 == undefined || mDowLoadServer1 == "") {
			mDowLoadServer1 = mDowLoadServer;
		}
		var mPutFile = eMailInfo.getPutFilePath(sandbox, mDownLoadFlag, 1);
		var mWpsFlag = $PublicFun.stringToInt($PublicFun.getPara(sandbox, "WPSFLG"));// sandbox.$instance.project.getParam("WPSFLG"));
		var data = {
			"op" : "SendEmail",
			"addr" : mAddress,
			"title" : mTitle,
			"content" : mContent,
			"files" : eMailInfo.attatchList,
			"mergeFiles" : eMailInfo.MergeList,
			"docLists" : eMailInfo.docList,
			"docMerges" : eMailInfo.docMergeList,
			"showFlag" : mShowMerge,
			"mergeData" : mMergeData,
			"downFlag" : mDownLoadFlag,
			"downServer" : mDowLoadServer,
			"downServer1" : mDowLoadServer1,// 用于上传
			"putFile" : mPutFile,
			"wps" : mWpsFlag
		};
		doType7_Send(data, mCallBackData, sandbox, oneCmd, logHead, 2);
	},

	doType7_3 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mAddress = "", mTitle = "", mContent = "", mAllFiles = "", mShowMerge = 0, mOtherValue = "", mBeginTime = "", mCallbackCmd = "";
		if (mArr.length > 0) {
			mAddress = mArr[0];
		}
		if (mArr.length > 1) {
			mTitle = mArr[1];
		}
		if (mArr.length > 2) {
			mAllFiles = mArr[2];
		}
		if (mArr.length > 3) {
			mShowMerge = $PublicFun.stringToInt(mArr[3]);
		}
		if (mArr.length > 4) {
			mOtherValue = mArr[4];
		}
		if (mArr.length > 5) {
			mBeginTime = mArr[5];
		}
		if (mArr.length > 6) {
			mCallbackCmd = mArr[6];
		}
		var mCallBackData = {};
		mCallBackData["cbCmd"] = mCallbackCmd;
		mCallBackData["addr"] = mAddress;
		mCallBackData["bd"] = mBeginTime;
		mCallBackData["other"] = mOtherValue;
		var iIndex = mAllFiles.indexOf("#*#");
		var mLocateFile = "", mTemplateFile = "";
		if (iIndex > -1) {
			mLocateFile = mAllFiles.substr(0, iIndex);
			mTemplateFile = mAllFiles.substr(iIndex + 3);
		} else {
			mLocateFile = mAllFiles;
			mTemplateFile = "";
		}
		var eMailInfo = new $PublicFun.$ADVLIB.EMAIL();
		if (eMailInfo.addAttatchFile(sandbox, mLocateFile, mTemplateFile) < 0) {
			$PublicFun.err("doType7_3", "发送FAX文件处理失败");
			// 失败;
		}
		var mMergeFlag = 0;
		if (eMailInfo.docMergeList > "" || eMailInfo.MergeList > "") {
			mMergeFlag = 1;
		}
		var mMergeData = "";
		if (mMergeFlag == 1) {
			mMergeData = doType7_BuildMergeValue(sandbox);
		}
		var mDownLoadFlag = $PublicFun.stringToInt($PublicFun.getPara(sandbox, "FMODE"));// sandbox.$instance.project.getParam("FMODE"));
		var mDowLoadServer = $PublicFun.getPara(sandbox, "FTPOUT");// sandbox.$instance.project.getParam("FTPOUT");
		if (mDowLoadServer == undefined) {
			mDowLoadServer = "";
		}
		var mDowLoadServer1 = $PublicFun.getPara(sandbox, "FTPOUF");// sandbox.$instance.project.getParam("FTPOUF");
		if (mDowLoadServer1 == undefined || mDowLoadServer1 == "") {
			mDowLoadServer1 = mDowLoadServer;
		}
		var mPutFile = eMailInfo.getPutFilePath(sandbox, mDownLoadFlag, 0);
		var mWpsFlag = $PublicFun.stringToInt($PublicFun.getPara(sandbox, "WPSFLG"));// sandbox.$instance.project.getParam("WPSFLG"));
		var data = {
			"op" : "SendFax",
			"addr" : mAddress,
			"title" : mTitle,
			"files" : eMailInfo.attatchList,
			"mergeFiles" : eMailInfo.MergeList,
			"docLists" : eMailInfo.docList,
			"docMerges" : eMailInfo.docMergeList,
			"showFlag" : mShowMerge,
			"mergeData" : mMergeData,
			"downFlag" : mDownLoadFlag,
			"downServer" : mDowLoadServer,
			"downServer1" : mDowLoadServer1,// 用于上传
			"putFile" : mPutFile,
			"wps" : mWpsFlag
		};
		doType7_Send(data, mCallBackData, sandbox, oneCmd, logHead, 3);
	},

	doType7_4 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mAddress = mArr[0];
		var mTitle = "", mContent = "", mOther = "", mBeginTime = "";
		if (mArr.length > 1) {
			mTitle = mArr[1];
		}
		if (mArr.length > 2) {
			mContent = mArr[2];
		}
		if (mArr.length > 3) {
			mOther = mArr[3];
		}
		if (mArr.length > 4) {
			mBeginTime = mArr[4];
		}
		var mFrom, mTo;
		var iTmp = mAddress.indexOf("|*|");
		if (iTmp > -1) {
			mFrom = mAddress.substring(0, iTmp);
			mTo = mAddress.substring(iTmp + 3);
		} else {
			mFrom = mAddress;
			mTo = "";
		}
		var mTryCount = $PublicFun.stringToInt($PublicFun.getPara(sandbox, 'TRYSST'));// sandbox.$instance.project.params['TRYSST'])
		if (mTryCount <= 0) {
			mTryCount = $PublicFun.stringToInt($PublicFun.getPara(sandbox, 'TRYOUT'));// sandbox.$instance.project.params['TRYOUT']);
		}
		var mNewID = $PublicFun.newGuid();
		// sandbox,otherFieldValue,sendKey,docType,status,tryCount,docPath,comment,vTo,vTo2,vTo3,vFromStr,vBeginTime
		if (doType7_4_sub(sandbox, mOther, mNewID, 3, 0, mTryCount, mContent, mTitle, mTo, "", "", mFrom, mBeginTime, []) > 0) {
			return setReturnValue(sandbox, oneCmd, mNewID, RefreshObj, logHead);
		} else {
			return setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
		}
	},

	doType7_5 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mDowLoadFlag = $PublicFun.stringToInt(mArr[0]);
		var mDowLoadServer = "", mSource = "", mTarget = "", mCallBack = "";
		if (mArr.length > 1) {
			mDowLoadServer = mArr[1];
		}
		if (mArr.length > 2) {
			mSource = mArr[2];
		}
		if (mArr.length > 3) {
			mTarget = mArr[3];
		}
		if (mArr.length > 4) {
			mCallBack = mArr[4];
		}
		var data = {
			"op" : "DownLoadFile",
			"flag" : mDowLoadFlag,
			"serverInfo" : mDowLoadServer,
			"sourceFile" : mSource,
			"targetFile" : mTarget
		};
		doType7_Send(data, mCallBack, sandbox, oneCmd, logHead, 5);
	},

	doType7_6 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		// vDownLoadFlag:String,vDownloadPara:String,vHeadPath:String, vFileName:String,vTargetFile:String
		var mDowLoadFlagPara = mArr[0];
		var mDowLoadServerPara = "", mHeadPath = "", mFileName = "", mTargetFile = "", mCallBack = "";
		if (mArr.length > 1) {
			mDowLoadServerPara = mArr[1].trim();
		}
		if (mArr.length > 2) {
			mHeadPath = mArr[2].trim();
		}
		if (mArr.length > 3) {
			mFileName = mArr[3];
		}
		if (mArr.length > 4) {
			mTargetFile = mArr[4];
		}
		if (mArr.length > 5) {
			mCallBack = mArr[6];
		}
		//
		var mDownLoadFlag = $PublicFun.stringToInt($PublicFun.getPara(sandbox, mDowLoadFlagPara));// sandbox.$instance.project.params[mDowLoadFlagPara]);
		var mDownLoadServer = $PublicFun.getPara(sandbox, mDowLoadServerPara);// sandbox.$instance.project.params[mDowLoadServerPara];
		if (mHeadPath.trim() == "") {
			mHeadPath = "";
		} else {
			mHeadPath = $PublicFun.getPara(sandbox, mHeadPath);// sandbox.$instance.project.params[mHeadPath];
		}
		mFileName = mHeadPath + mFileName;
		$PublicFun.log("CustDownLoad", "Flag:" + mDownLoadFlag + " Server:" + mDownLoadServer + " FileName:" + mFileName);
		var data = {
			"op" : "DownLoadFile",
			"flag" : mDownLoadFlag,
			"serverInfo" : mDownLoadServer,
			"sourceFile" : mFileName,
			"targetFile" : mTargetFile
		};
		doType7_Send(data, mCallBack, sandbox, oneCmd, logHead, 6);
	},

	doType7_7 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mDowLoadFlag = $PublicFun.stringToInt(mArr[0]);
		var mDowLoadServer = "", mSource = "", mTarget = "", mCallBack = "";
		if (mArr.length > 1) {
			mDowLoadServer = mArr[1].trim();
		}
		if (mArr.length > 2) {
			mSource = mArr[2].trim();
		}
		if (mArr.length > 3) {
			mTarget = mArr[3].trim();
		}
		if (mArr.length > 4) {
			mCallBack = mArr[4].trim();
		}
		var data = {
			"op" : "PutFile",
			"flag" : mDowLoadFlag,
			"serverInfo" : mDowLoadServer,
			"sourceFile" : mSource,
			"targetFile" : mTarget
		};
		doType7_Send(data, mCallBack, sandbox, oneCmd, logHead, 7);
	},

	doType7_8 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		// vDownLoadFlag:String,vDownloadPara:String,vHeadPath:String, vFileName:String,vTargetFile:String
		var mDowLoadFlagPara = mArr[0];
		var mDowLoadServerPara = "", mHeadPath = "", mFileName = "", mTargetFile = "", mCallBack = "";
		if (mArr.length > 1) {
			mDowLoadServerPara = mArr[1].trim();
		}
		if (mArr.length > 2) {
			mHeadPath = mArr[2].trim();
		}
		if (mArr.length > 3) {
			mFileName = mArr[3].trim();
		}
		if (mArr.length > 4) {
			mTargetFile = mArr[4].trim();
		}
		if (mArr.length > 5) {
			mCallBack = mArr[5].trim();
		}
		var mDownLoadFlag = $PublicFun.stringToInt($PublicFun.getPara(sandbox, mDowLoadFlagPara));// sandbox.$instance.project.params[mDowLoadFlagPara]);
		var mDownLoadServer = $PublicFun.getPara(sandbox, mDowLoadServerPara);// sandbox.$instance.project.params[mDowLoadServerPara];
		if (mHeadPath.trim() == "") {
			mHeadPath = "";
		} else {
			mHeadPath = $PublicFun.getPara(sandbox, mHeadPath);// sandbox.$instance.project.params[mHeadPath];
		}
		mTargetFile = mHeadPath + mTargetFile;
		$PublicFun.log("CustPutFile", "Flag:" + mDownLoadFlag + " Server:" + mDownLoadServer + " TargetFileName:" + mFileName);
		var data = {
			"op" : "PutFile",
			"flag" : mDownLoadFlag,
			"serverInfo" : mDownLoadServer,
			"sourceFile" : mFileName,
			"targetFile" : mTargetFile
		};
		doType7_Send(data, mCallBack, sandbox, oneCmd, logHead, 8);
	},

	doType7_9 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mTitle = mArr[0];
		if (mArr.length < 3) {
			$PublicFun.err("doType7_9", "参数不正确");
			return setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
		}
		var mCallBackCmd = mArr[3];
		if (mCallBackCmd == undefined) {
			mCallBackCmd = "";
		} else {
			mCallBackCmd = mCallBackCmd.trim();
		}
		var data = {
			"op" : "SelectRead",
			"titile" : mTitle,
			"filter" : mArr[1],
			"default" : mArr[2]
		};
		doType7_Send(data, mCallBackCmd, sandbox, oneCmd, logHead, 9);
	},

	doType7_10 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mTitle = mArr[0];
		if (mArr.length < 3) {
			$PublicFun.err("doType7_10", "参数不正确");
			return setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
		}
		var mCallBackCmd = mArr[3];
		if (mCallBackCmd == undefined) {
			mCallBackCmd = "";
		} else {
			mCallBackCmd = mCallBackCmd.trim();
		}
		var data = {
			"op" : "SelectSave",
			"titile" : mTitle,
			"filter" : mArr[1],
			"default" : mArr[2]
		};
		doType7_Send(data, mCallBackCmd, sandbox, oneCmd, logHead, 10);
	},

	doType7_11 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		if (mArr.length < 2) {
			$PublicFun.err("doType7_11", "参数不正确");
			return setReturnValue(sandbox, oneCmd, "-1", RefreshObj, logHead);
		}
		var mSourceFile = mArr[0];
		var mTargetFile = mArr[1];
		if ((mSourceFile || '') == "") {
			$PublicFun.err("doType7_11", "参数不正确:源文件名为空");
			return setReturnValue(sandbox, oneCmd, "-1", RefreshObj, logHead);
		}
		if ((mTargetFile || '') == "") {
			$PublicFun.err("doType7_11", "参数不正确:目标文件名为空");
			return setReturnValue(sandbox, oneCmd, "-1", RefreshObj, logHead);
		}
		var mCallBackCmd = mArr[2];
		if (mCallBackCmd == undefined) {
			mCallBackCmd = "";
		} else {
			mCallBackCmd = mCallBackCmd.trim();
		}
		var data = {
			"op" : "FileCopy",
			"sourceFile" : mSourceFile,
			"targetFile" : mTargetFile
		};
		doType7_Send(data, mCallBackCmd, sandbox, oneCmd, logHead, 11);
	},

	doType7_12 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mSourceFile = mArr[0];
		if ((mSourceFile || '') == "") {
			$PublicFun.err("doType7_12", "参数不正确:删除文件名为空");
			return setReturnValue(sandbox, oneCmd, "-1", RefreshObj, logHead);
		}
		var mCallBackCmd = mArr[1];
		if (mCallBackCmd == undefined) {
			mCallBackCmd = "";
		} else {
			mCallBackCmd = mCallBackCmd.trim();
		}
		var data = {
			"op" : "DelFile",
			"fileName" : mSourceFile
		};
		doType7_Send(data, mCallBackCmd, sandbox, oneCmd, logHead, 12);
	},

	doType7_13 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mFileName = mArr[0];
		var mContent = mArr[1];
		var mCallBackCmd = mArr[2];
		if (mFileName == undefined || mFileName.trim() == "") {
			$PublicFun.err("doType7_13", logHead + " 未指定写的文件名");
			return setReturnValue(sandbox, oneCmd, "-1", RefreshObj, logHead);
		}
		if (mCallBackCmd == undefined) {
			mCallBackCmd = "";
		} else {
			mCallBackCmd = mCallBackCmd.trim();
		}
		var data = {
			"op" : "WriteFile",
			"fileName" : mFileName,
			"content" : mContent
		}
		doType7_Send(data, mCallBackCmd, sandbox, oneCmd, logHead, 13);
	},

	doType7_14 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mFileName = mArr[0];
		var mMsgFlag = $PublicFun.stringToInt(mArr[1]);
		var mCallBackCmd = mArr[2];
		if (mFileName == undefined || mFileName.trim() == "") {
			$PublicFun.err("doType7_14", logHead + " 未指定文件名");
			return setReturnValue(sandbox, oneCmd, "-1", RefreshObj, logHead);
		}
		if (mCallBackCmd == undefined) {
			mCallBackCmd = "";
		} else {
			mCallBackCmd = mCallBackCmd.trim();
		}
		var data = {
			"op" : "ShowFile",
			"files" : mFileName,
			"msgFlag" : mMsgFlag
		}
		doType7_Send(data, mCallBackCmd, sandbox, oneCmd, logHead, 14);
	},

	doType7_16 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mFileName = mArr[0];
		if (mFileName == undefined || mFileName.trim() == "") {
			$PublicFun.err("doType7_16", logHead + " 未指定播放的文件名");
			return setReturnValue(sandbox, oneCmd, "-1", RefreshObj, logHead);
		}
		$PublicFun.playVoice(mFileName);
		return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
	},

	doType7_17 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);
		// vGetFlag:int,vGetServerInfo:String,vSourceFile:String,vFileFormat:int
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mGetFlag = $PublicFun.stringToInt(mArr[0]);
		var mGetServer = mArr[1];
		var mSourceFile = mArr[2];
		var mFileFormat = $PublicFun.stringToInt(mArr[3]);
		var mCallBack = mArr[4];
		if (mSourceFile == undefined || mSourceFile.trim() == "") {
			$PublicFun.err("doType7_17", logHead + " 未指定下载的录音文件名");
			return setReturnValue(sandbox, oneCmd, "-1", RefreshObj, logHead);
		}
		var mCallBackCmd;
		if (mCallBack == undefined) {
			mCallBackCmd = "";
		} else {
			mCallBackCmd = mCallBack.trim();
		}
		var vfType = $PublicFun.getPara(sandbox, "VFTYPE");// sandbox.$instance.project.params['VFTYPE'];
		var fixType = $PublicFun.getPara(sandbox, "SFTYPE");// sandbox.$instance.project.params['SFTYPE'];
		var data = {
			"op" : "GetVoice",
			"dFlag" : mGetFlag,
			"dServer" : mGetServer,
			"source" : mSourceFile,
			"fileFormat" : mFileFormat,
			"vfType" : vfType,
			"fix" : fixType
		}
		doType7_Send(data, mCallBackCmd, sandbox, oneCmd, logHead, 17);
	},

	doType7_18 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mGetFlagPara = mArr[0].trim();
		var mGetServerPara = mArr[1].trim();
		var mGetHead = mArr[2].trim();
		var mSourceFile = mArr[3].trim();
		var mFileFormat = $PublicFun.stringToInt(mArr[4]);
		var mCallBack = mArr[5];

		var mGetFlag = $PublicFun.getPara(sandbox, mGetFlagPara);// sandbox.$instance.project.params[mGetFlagPara];
		var mGetServer = $PublicFun.getPara(sandbox, mGetServerPara);// sandbox.$instance.project.params[mGetServerPara];
		mSourceFile = mGetHead + mSourceFile;
		if (mSourceFile == undefined || mSourceFile.trim() == "") {
			$PublicFun.err("doType7_18", logHead + " 未指定下载的录音文件名");
			return setReturnValue(sandbox, oneCmd, "-1", RefreshObj, logHead);
		}
		$PublicFun.log("doType7_18", " getFlag:" + mGetFlag + " getServer:" + mGetServer + " GetFile:" + mSourceFile);
		var mCallBackCmd;
		if (mCallBack == undefined) {
			mCallBackCmd = "";
		} else {
			mCallBackCmd = mCallBack.trim();
		}
		var vfType = $PublicFun.getPara(sandbox, 'VFTYPE');// sandbox.$instance.project.params['VFTYPE'];
		var fixType = $PublicFun.getPara(sandbox, 'SFTYPE');// sandbox.$instance.project.params['SFTYPE'];
		var data = {
			"op" : "GetVoice",
			"dFlag" : mGetFlag,
			"dServer" : mGetServer,
			"source" : mSourceFile,
			"fileFormat" : mFileFormat,
			"vfType" : vfType,
			"fix" : fixType
		}
		doType7_Send(data, mCallBackCmd, sandbox, oneCmd, logHead, 18);
	},

	doType7_19 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|$|");
		var mFileName = mArr[0];
		if (mFileName == undefined || mFileName.trim() == "") {
			$PublicFun.err("doType7_19", "未指定去除密码的文件名");
			return setReturnValue(sandbox, oneCmd, "-1", RefreshObj, logHead);
		}
		if (mArr.length < 3) {
			$PublicFun.err("doType7_19", "参数不正确");
			return setReturnValue(sandbox, oneCmd, "-1", RefreshObj, logHead);
		}
		var mCallBackCmd = mArr[3];
		if (mCallBackCmd == undefined) {
			mCallBackCmd = "";
		} else {
			mCallBackCmd = mCallBackCmd.trim();
		}
		var data = {
			"op" : "RemoveExcelPwd",
			"filename" : mFileName,
			"pwd1" : mArr[1],
			"pwd2" : mArr[2]
		};
		doType7_Send(data, mCallBackCmd, sandbox, oneCmd, logHead, 19);
	},

	doType7_Send = function(data, callBackCmd, sandbox, oneCmd, logHead, flagIndex) {
		var busyId = $F.busyShow();
		var ev = {
			sc : busyId,
			cb : callBackCmd,
			r : sandbox,
			c : oneCmd,
			l : logHead,
			flag : flagIndex
		}
		// $E.ws.local.send("Locate",data,doType7_CallBack,ev)
		$E.ws.local.send("LocExe", data, doType7_CallBack, ev)
	},

	doType7_CallBack = function(data, ev) {
		if (ev == undefined) {
			$PublicFun.err("doType7_CallBack", "未得到传入环境信息:" + JSON.stringify(data));
			return;
		}
		$F.busyHide(ev.sc);
		var mFlag = ev.flag;
		if (mFlag == undefined) {
			$PublicFun.err("doType7_CallBack", ev.logHead + " 未得到传入环境标志信息:" + JSON.stringify(data));
			return;
		}
		var RefrObj = {};
		var mRetrunCode, mReturnData, mReturnMsg;
		mRetrunCode = data.code;
		mReturnData = data.result;
		mReturnMsg = data.message;
		switch (mFlag) {
		case 1: // 文件合并
			setReturnValue(ev.r, ev.c, data.code, RefrObj, ev.l);
			break;
		case 2: // SENDEMAIL
			doType7_2_CallBack(data, ev, RefrObj);
			return; // 需要退出
		case 3: // SENDFAX
			doType7_3_CallBack(data, ev, RefrObj);
			return; // 需要退出
			// case 4: //SENDSMS 非异步
		case 5: // DOWNLOADFILE
			setReturnValue(ev.r, ev.c, data.code, RefrObj, ev.l);
			// mReturnData=data.code;
			break;
		case 6: // CUSTDOWNFILE ，根据系统参数下传
			setReturnValue(ev.r, ev.c, data.code, RefrObj, ev.l);
			// mReturnData=data.code;
			break;
		case 7: // PUTONEFILE
			setReturnValue(ev.r, ev.c, data.code, RefrObj, ev.l);
			// mReturnData=data.code;
			break;
		case 8: // CUSTPFILE, 根据系统参数上传
			setReturnValue(ev.r, ev.c, data.code, RefrObj, ev.l);
			// mReturnData=data.code;
			break;
		case 9: // FILESELECT
			setReturnValue(ev.r, ev.c, data.result, RefrObj, ev.l);
			// mReturnData=data.result;
			break;
		case 10: // FILESAVE
			setReturnValue(ev.r, ev.c, data.result, RefrObj, ev.l);
			// mReturnData=data.result;
			break;
		case 11:// FILECOPY
			setReturnValue(ev.r, ev.c, data.code, RefrObj, ev.l);
			// mReturnData=data.code;
			break;
		case 12: // FILEDELETE
			setReturnValue(ev.r, ev.c, data.code, RefrObj, ev.l);
			// mReturnData=data.code;
			break;
		case 13: // FILEWRITE
			setReturnValue(ev.r, ev.c, data.code, RefrObj, ev.l);
			// mReturnData=data.code;
			break;
		case 14: // SHOWFILE
			setReturnValue(ev.r, ev.c, data.result, RefrObj, ev.l);
			// mReturnData=data.result;
			break;
		// case 15: //show Pop IE 非异步
		// case 16: //PLAYVOICE 非异步
		// break;
		case 17: // GETVOICE
			setReturnValue(ev.r, ev.c, data.result, RefrObj, ev.l);
			// mReturnData=data.result;
			break;
		case 18: // GETVOICEPARA
			setReturnValue(ev.r, ev.c, data.result, RefrObj, ev.l);
			// mReturnData=data.result;
			break;
		case 19: // EXCELAS
			setReturnValue(ev.r, ev.c, data.code, RefrObj, ev.l);
			// mReturnData=data.code;
			break;
		default:
			$PublicFun.err("doType7_CallBack", "未知的传入环境标志信息:" + JSON.stringify(data));
			return;
		}
		if (ev.r.$callback != undefined) {
			ev.r.$callback(RefrObj, ev.r.$runtime);
		}
		if (ev.cb > "") {
			doType7_DoCallBackCmd(ev.r, ev.cb, mRetrunCode, mReturnData, mReturnMsg);
		}
	},

	doType7_2_CallBack = function(data, ev, RefrObj) {
		if (data.code < 1) {
			setReturnValue(ev.r, ev.c, -1, RefrObj, ev.l);
			if (ev.r.$callback != undefined) {
				ev.r.$callback(RefrObj, ev.r.$runtime);
			}
			if (ev.cb["cbCmd"] > "") {
				doType7_DoCallBackCmd(ev.r, ev.cb["cbCmd"], -1, "", data.message);
			}
			return;
		}
		var mTryCount = $PublicFun.stringToInt($PublicFun.getPara(ev.r, 'TRYSST'));// ev.r.$instance.project.params['TRYEST'])
		if (mTryCount <= 0) {
			mTryCount = $PublicFun.stringToInt($PublicFun.getPara(ev.r, 'TRYOUT'));// ev.r.$instance.project.params['TRYOUT']);
		}
		var mNewID = $PublicFun.newGuid();
		var mCB = ev.cb["cbCmd"];
		var mAdd = ev.cb["addr"];
		var mTitle = ev.cb["title"];
		var mBeginTime = ev.cb["bd"];
		var mOtherV = ev.cb["other"];
		var mFrom = "", mTo = "", mCC = "", mBCC = "";
		var mArrayAddress = $PublicFun.stringToArray(mAdd, "|*|"); // From ,To,CC , BCC
		if (mArrayAddress.length > 0) {
			mFrom = mArrayAddress[0];
			if (mArrayAddress.length > 1) {
				mTo = mArrayAddress[1];
				if (mArrayAddress.length > 2) {
					mCC = mArrayAddress[2];
					if (mArrayAddress.length > 3) {
						mBCC = mArrayAddress[3];
					}
				}
			}
		}
		var mReturnData;
		if (doType7_4_sub(ev.r, mOtherV, mNewID, 2, 0, mTryCount, data.result, mTitle, mTo, mCC, mBCC, mFrom, mBeginTime, []) > 0) {
			setReturnValue(ev.r, ev.c, data.code, RefrObj, ev.l);
			mReturnData = 1
		} else {
			$PublicFun.err("SendEmail", "插入数据库记录失败");
			setReturnValue(ev.r, ev.c, -1, RefrObj, ev.l);
			mNewID = "";
			mReturnData = -1
		}
		if (ev.r.$callback != undefined) {
			ev.r.$callback(RefrObj, ev.r.$runtime);
		}
		if (mCB > "") {
			doType7_DoCallBackCmd(ev.r, mCB, mReturnData, mNewID, "");
		}
	},

	doType7_3_CallBack = function(data, ev, RefrObj) {
		if (data.code < 1) {
			setReturnValue(ev.r, ev.c, -1, RefrObj, ev.l);
			if (ev.r.$callback != undefined) {
				ev.r.$callback(RefrObj, ev.r.$runtime);
			}
			if (ev.cb["cbCmd"] > "") {
				doType7_DoCallBackCmd(ev.r, ev.cb["cbCmd"], -1, "", data.message);
			}
			return;
		}
		var mTryCount = $PublicFun.stringToInt($PublicFun.getPara(ev.r, 'TRYFST'));// ev.r.$instance.project.params['TRYFST'])
		if (mTryCount <= 0) {
			mTryCount = $PublicFun.stringToInt($PublicFun.getPara(ev.r, 'TRYOUT'));// ev.r.$instance.project.params['TRYOUT']);
		}
		var mNewID = $PublicFun.newGuid();
		var mCB = ev.cb["cbCmd"];
		var mAdd = ev.cb["addr"];
		var mTitle = ev.cb["title"];
		var mBeginTime = ev.cb["bd"];
		var mOtherV = ev.cb["other"];
		var mFrom = "", mTo = "", mCC = "", mBCC = "";
		var mArrayAddress = $PublicFun.stringToArray(mAdd, "|*|"); // From ,To
		if (mArrayAddress.length > 0) {
			mFrom = mArrayAddress[0];
			if (mArrayAddress.length > 1) {
				mTo = mArrayAddress[1];
			}
		}
		var mSubFile = $PublicFun.stringToArray(data.result, ";");
		var mReturnData;
		if (doType7_4_sub(ev.r, mOtherV, mNewID, 1, 0, mTryCount, "", mTitle, mTo, "", "", mFrom, mBeginTime, mSubFile) > 0) {
			setReturnValue(ev.r, ev.c, data.code, RefrObj, ev.l);
			mReturnData = 1
		} else {
			$PublicFun.err("SendFax", "插入数据库记录失败");
			setReturnValue(ev.r, ev.c, -1, RefrObj, ev.l);
			mNewID = "";
			mReturnData = -1
		}
		if (ev.r.$callback != undefined) {
			ev.r.$callback(RefrObj, ev.r.$runtime);
		}
		if (mCB > "") {
			doType7_DoCallBackCmd(ev.r, mCB, mReturnData, mNewID, "");
		}
	}, doType7_BuildMergeValue = function(sandbox) {
		var mStrResult = "<ALLV><LOC>";
		// 临时变量
		for ( var mName in sandbox.R) {
			mStrResult += "<L><N><![CDATA[" + mName.toUpperCase() + "]]></N>"
			mStrResult += "<V><![CDATA[" + sandbox.R[mName] + "]]></V></L>"
		}
		mStrResult += "</LOC>";
		for ( var mName in sandbox.$pubData) {
			mStrResult += "<" + mName.trim().toUpperCase() + ">";
			var mSubData = sandbox.$pubData[mName];
			for ( var mSubN in mSubData) {
				var mSubValue = mSubData[mSubN];
				if (mSubValue instanceof Array) {
					mStrResult += "<" + mSubN.trim().toUpperCase() + ">";
					var iCount = mSubValue.length;
					for (var i = 0; i < iCount; i++) {
						var jCount = mSubValue[i].length;
						mStrResult += "<R>";
						for (var j = 0; j < jCount; j++) {
							mStrResult += "<C" + (j + 1) + "><![CDATA[";
							mStrResult += mSubValue[i][j];
							mStrResult += "]]></C" + (j + 1) + ">";
						}
						mStrResult += "</R>";
					}
					mStrResult += "</" + mSubN.trim().toUpperCase() + ">";
				} else {
					mStrResult += "<" + mSubN.trim().toUpperCase() + "><![CDATA[";
					mStrResult += mSubValue + "]]></" + mSubN.trim().toUpperCase() + ">";
				}
			}
			mStrResult += "</" + mName.trim().toUpperCase() + ">";
		}
		// 客户资料及当前信息
		mStrResult += "<SYS><STAFFID>" + $E.staff.id + "</STAFFID>";
		mStrResult += "<STAFFNAME>" + $E.staff.name + "</STAFFNAME>";
		mStrResult += "<AGENTID>" + $E.staff.agentId + "</AGENTID>";
		mStrResult += "<EPID>" + $E.staff.epid + "</EPID>";
		mStrResult += "<ROLEGROUPID>" + sandbox.$instance.project.groupId + "</ROLEGROUPID>";
		mStrResult += "<ROLEGROUPNAME>" + sandbox.$instance.project.groupName + "</ROLEGROUPNAME>";
		// if (ECore.callInfo!=null){
		// mStrResult+="<ANI>"+ECore.callInfo.ani +"</ANI>";
		// mStrResult+="<DNIS>"+ECore.callInfo.dnis +"</DNIS>";
		// mStrResult+="<CALLTYPE>"+String(ECore.callInfo.callType)+"</CALLTYPE>";
		// mStrResult+="<CUREVENTID>"+ECore.callInfo.eventGuid+"</CUREVENTID>";
		// mStrResult+="<EXTENSION>"+ECore.callInfo.extension+"</EXTENSION>";
		// }
		
		var isSupervisor = parseInt(sandbox.$project.getParam('ISSUPE', 2));
		mStrResult += "<G_ISSUPER>" + ((isSupervisor > $E.staff.supervisor) ? 1 : 0) + "</G_ISSUPER>";
		mStrResult += "<G_SFASHA>" + parseInt(sandbox.$project.getParam('SFASHA', 0)) + "</G_SFASHA>";

		mStrResult += "</SYS>";

		var customer = sandbox.$instance.customer;// .values;
		if (customer) {
			mStrResult += "<CUSTOMER>";
			for ( var mTmp in customer.values) {
				mStrResult += "<" + mTmp.trim().toUpperCase() + "><![CDATA[";
				mStrResult += customer.values[mTmp] + "]]></" + mTmp.trim().toUpperCase() + ">";
			}
			mStrResult += "</CUSTOMER>";
		}
		mStrResult += "</ALLV>";
		return mStrResult;
	}, 
	
	doType7 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		// var mArr=stringtoarray(content.c, "|$|");
		switch (content.t) {
		case 1: // 文件合并
			return doType7_1(sandbox, oneCmd, RefreshObj, logHead);
		case 2: // SENDEMAIL
			return doType7_2(sandbox, oneCmd, RefreshObj, logHead);
		case 3: // SENDFAX
			return doType7_3(sandbox, oneCmd, RefreshObj, logHead);
		case 4: // SENDSMS
			return doType7_4(sandbox, oneCmd, RefreshObj, logHead);
		case 5: // DOWNLOADFILE
			return doType7_5(sandbox, oneCmd, RefreshObj, logHead);
		case 6: // CUSTDOWNFILE ，根据系统参数下传
			return doType7_6(sandbox, oneCmd, RefreshObj, logHead);
		case 7: // PUTONEFILE
			return doType7_7(sandbox, oneCmd, RefreshObj, logHead);
		case 8: // CUSTPFILE, 根据系统参数上传
			return doType7_8(sandbox, oneCmd, RefreshObj, logHead);
		case 9: // FILESELECT
			return doType7_9(sandbox, oneCmd, RefreshObj, logHead);
		case 10: // FILESAVE
			return doType7_10(sandbox, oneCmd, RefreshObj, logHead);
		case 11:// FILECOPY
			return doType7_11(sandbox, oneCmd, RefreshObj, logHead);
		case 12: // FILEDELETE
			return doType7_12(sandbox, oneCmd, RefreshObj, logHead);
		case 13: // FILEWRITE
			return doType7_13(sandbox, oneCmd, RefreshObj, logHead);
		case 14: // SHOWFILE
			return doType7_14(sandbox, oneCmd, RefreshObj, logHead);
		case 15: // show Pop IE
			return doType7_15(sandbox, oneCmd, RefreshObj, logHead);
		case 16: // PLAYVOICE
			return doType7_16(sandbox, oneCmd, RefreshObj, logHead);
		case 17: // GETVOICE
			return doType7_17(sandbox, oneCmd, RefreshObj, logHead);
		case 18: // GETVOICEPARA
			return doType7_18(sandbox, oneCmd, RefreshObj, logHead);
		case 19: // EXCELAS
			return doType7_19(sandbox, oneCmd, RefreshObj, logHead);
		}
		return 1;
	}, 
	
	/**
	 * 执行JavaScript脚本
	 */
	doType3 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var exp = $DynFun.replaceCalcContent(sandbox, oneCmd, oneCmd.C.c, 0);
		return setReturnValue(sandbox, oneCmd, sandbox.evalValue(exp.replace(/\beval\((.*)\)/gi, '$1')), RefreshObj, logHead);
	}, 
	
	doType1_1 = function(sandbox, oneCmd, RefreshObj, logHead) {
		//var mSqlKey=oneCmd.C.k
		var mRs = $F.ajaxSync("CacheDoMDL2", {
			token : sandbox.$token,
			dbPool : "",
			sqls : [ {
				cacheId : sandbox.$dynId,
				sqlId : oneCmd.C.c,
				para : getMDLServerPara(sandbox, oneCmd.C.c)
			} ]
		}, sandbox.$digest);
		// console.log(mRs);
		if (mRs) {
			if (mRs.code > -1) {
				var tmpV = mRs.value[0];
				if (tmpV) {
					if (tmpV.count > -1) {
						setReturnValue(sandbox, oneCmd, tmpV.fields, RefreshObj, logHead);
					} else {
						$PublicFun.err("doType1_1", logHead + " 获取模板数据失败，没有得到返回数据，count<0,SQL执行失败");
						setReturnValue(sandbox, oneCmd, [], RefreshObj, logHead);
					}
				} else {
					$PublicFun.err("doType1_1", logHead + " 获取模板数据失败，没有得到返回数据");
					setReturnValue(sandbox, oneCmd, [], RefreshObj, logHead);
				}
			} else {
				$PublicFun.err("doType1_1", logHead + " 获取模板数据失败：" + mRs.message);
				setReturnValue(sandbox, oneCmd, [], RefreshObj, logHead);
			}
		} else {
			$PublicFun.err("doType1_1", logHead + " 获取模板数据失败,异常错误");
			setReturnValue(sandbox, oneCmd, [], RefreshObj, logHead);
		}
		return 1;
	}, doType1_2 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mRs = $F.ajaxSync("CacheDoMDL1", {
			token : sandbox.$token,
			dbPool : "",
			sqls : [ {
				cacheId : sandbox.$dynId,
				sqlId : oneCmd.C.c,
				para : getMDLServerPara(sandbox, oneCmd.C.c)
			} ]
		}, sandbox.$digest);
		if (mRs) {
			setReturnValue(sandbox, oneCmd, mRs.code, RefreshObj, logHead);
			if (mRs.code < 0) {
				$PublicFun.log("ExecMDLSql", logHead + " Failed:" + mRs.message);
			}
		} else {
			$PublicFun.err("ExecMDLSql", logHead + " Failed Unknow Error");
			setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
		return 0;
	}, doType1_3 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var str = oneCmd.C.c;

		if (str) {
			var iTmp = str.indexOf("||");
			if (iTmp > -1) {
				var mL = $DynFun.replaceCalcContent(sandbox, oneCmd, str.substring(0, iTmp), 0);
				var mR = $DynFun.replaceCalcContent(sandbox, oneCmd, str.substring(iTmp + 2), 0);
				var mResult = $PublicFun.stringToArray(mL, mR);
				setReturnValue(sandbox, oneCmd, mResult, RefreshObj, logHead);
			} else {
				setReturnValue(sandbox, oneCmd, [], RefreshObj, logHead);
			}
		} else {
			setReturnValue(sandbox, oneCmd, [], RefreshObj, logHead);
		}
		return 0;
	}, doType1_4 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);
		var mArray = mTmpContent.split(",");
		var mObjTypeId = "", mAssignFlag = 0, mAssignGrp = "", mAssignBy = "", mExpBD = "", mExpED = "", mTimes = 0, mCustGuid = "", mPreObjID = "";
		if (mArray.length > 0) {
			mObjTypeId = mArray[0];
		}
		if (mObjTypeId == "") {
			$PublicFun.err("doType1_4", "市场活动不存在");
			setReturnValue(sandbox, OneCmd, -1, RefreshObj, logHead);
			return 0;
		}
		if (mArray.length > 1) {
			mAssignFlag = $PublicFun.stringToInt(mArray[1]);
		}
		if (mArray.length > 2) {
			mAssignGrp = mArray[2].toString();
		}
		if (mAssignGrp == "") {
			$PublicFun.err("doType1_4", "分配的组不存在");
			setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			return 0;
		}
		if (mArray.length > 3) {
			mAssignBy = mArray[3].toString();
		}
		if (mArray.length > 4) {
			mExpBD = mArray[4].toString();
		}
		if (mExpBD == "") {
			mExpBD = sandbox.getdbtime();
		}
		if (mArray.length > 5) {
			mExpED = mArray[5].trim();
		}
		if (mArray.length > 6) {
			mTimes = $PublicFun.stringToInt(mArray[6]);
		}
		if (mArray.length > 7) {
			mCustGuid = mArray[7].trim();
		}
		if (mArray.length > 8) {
			mPreObjID = mArray[8].trim();
		}
		if (mCustGuid == "") {
			mCustGuid = $DynFun.getCustInfo(sandbox, "customer_guid");
			if (mCustGuid == "") {
				$PublicFun.err("BuildOBJ", "生成市场活动错误:没有当前客户信息");
				return 0;
			}
		}
		var mTmpGUID = $PublicFun.newGuid();
		var mRs = $F.ajaxSync("SystemDo1", {
			token : sandbox.$token,
			dbPool : "",
			sqls : [ {
				key : "DynBD.Exec.NewObj",
				params : {
					C1 : $E.staff.epidSql,
					C2 : mTmpGUID,
					C3 : mObjTypeId,
					C4 : mAssignGrp,
					C5 : mAssignBy,
					C6 : mExpED,
					C7 : mCustGuid,
					C8 : mTimes,
					C9 : mPreObjID
				}
			}, {
				key : "DynBD.Exec.NewOB",
				params : {
					C1 : $E.staff.epidSql,
					C2 : mTmpGUID,
					C3 : mTmpGUID,
					C4 : mObjTypeId,
					C5 : mExpBD,
					C6 : mExpED,
					C7 : mTimes,
					C8 : mAssignGrp,
					C9 : mAssignBy
				}
			} ]
		}, sandbox.$digest);
		if (mRs) {
			setReturnValue(sandbox, oneCmd, mRs.code, RefreshObj, logHead);
			if (mRs.code < 0) {
				$PublicFun.log("New OB Info", logHead + " Failed:" + mRs.message);
			}
		} else {
			$PublicFun.err("New OB Info", logHead + " Failed Unknow Error");
			setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
		return 1;
	}, 
	
	doType1 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		switch (content.t) {
		case 0: // 清空
			return setReturnValue(sandbox, oneCmd, [], RefreshObj, logHead);
		case 1: // 选取模板记录
			return doType1_1(sandbox, oneCmd, RefreshObj, logHead);
		case 2: // 执行模板记录
			return doType1_2(sandbox, oneCmd, RefreshObj, logHead);
		case 3: // 分隔字符串
			return doType1_3(sandbox, oneCmd, RefreshObj, logHead);
		case 4: // 插入市场活动
			return doType1_4(sandbox, oneCmd, RefreshObj, logHead);
		}
	}, 

	doType6_CallBack = function(data, ev) {
		if (ev == undefined) {
			$PublicFun.err("doType6_CallBack", "未得到传入环境信息:" + datd);
			return;
		}
		$F.busyHide(ev.sc);
		var RefrObj = {};
		var mRetrunCode;
		if (data) {
			mRetrunCode = 1;
		} else {
			mRetrunCode = -1;
		}
		setReturnValue(ev.r, ev.c, mRetrunCode, RefrObj, ev.l);
		if (ev.r.$callback != undefined) {
			ev.r.$callback(RefrObj, ev.r.$runtime);
		}
		if (ev.cb > "") {
			doType7_DoCallBackCmd(ev.r, ev.cb, mRetrunCode, "", "");
		}
	},doType6 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		var mArr = $PublicFun.stringToArray(mTmpContent, "|*|");
		var mTmp1 = "", mTmp2 = "", mTmp3 = "";
		if (mArr.length > 0) {
			mTmp1 = mArr[0];
		}
		if (mArr.length > 1) {
			mTmp2 = mArr[1];
		}
		if (mArr.length > 2) {
			mTmp3 = mArr[2];
		}
		
		$PublicFun.$CTI.ctiDo(content.t,mTmp1,mTmp2,mTmp3,sandbox,oneCmd,doType6_CallBack,logHead);
	}, 
	
	doType4 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c, 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		if (mTmpContent) {
			var mArray = mTmpContent.split(",");
			if (mArray.length < 2) {
				$PublicFun.err("doType4", "弹出页面传入参数不正确:" + mTmpContent);
				return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			}
			var mObjectID = mArray[1].trim();
			var mBuildID = mArray[0].trim();
			var mCmdID = "";
			if (mArray.length > 2) {
				mCmdID = mArray[2].trim();
			}
			var mModelFlag = false;
			if (mArray.length > 3) {
				if ($PublicFun.stringToInt(mArray[3]) == 1) {
					mModelFlag = true;
				} else {
					mModelFlag = false;
				}
			}
			var mTop = 100;
			if (mArray.length > 4) {
				mTop = $PublicFun.stringToInt(mArray[4]);
			}
			var mLeft = 100;
			if (mArray.length > 5) {
				mLeft = $PublicFun.stringToInt(mArray[5]);
			}
			var mWidth = 600;
			if (mArray.length > 6) {
				mWidth = $PublicFun.stringToInt(mArray[6]) / 15;
			}
			var mHeight = 300;
			if (mArray.length > 7) {
				mHeight = $PublicFun.stringToInt(mArray[7]) / 15;
			}
			var mPopKey = "";
			if (mArray.length > 8) {
				mPopKey = mArray[8].trim();
			}
			var mTitle = "";
			if (mArray.length > 9) {
				mTitle = mArray[9].trim();
			}
			var mMax = 0, mMin = 0, mClose = 0;
			if (mArray.length > 10) {
				mMax = $PublicFun.stringToInt(mArray[10]);
			}
			if (mArray.length > 11) {
				mMin = $PublicFun.stringToInt(mArray[11]);
			}
			if (mArray.length > 12) {
				mClose = $PublicFun.stringToInt(mArray[12]);
			}
			// sandbox.$instance
			// sandbox.R
			// console.log("PopKey:"+mPopKey);
			$D.popup(mPopKey, mBuildID, mObjectID, "", sandbox.$instance, mCmdID, sandbox.R, {
				title : mTitle,
				model : mModelFlag,
				width : mWidth,
				height : mHeight,
				left : mLeft,
				top : mTop,
				minable : mMin,
				maxable : mMax,
				closable : mClose
			})
			return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
		} else {
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
	},
	_1a= function(sandbox, oneCmd, mPara,flag) {
        var _1 = {};
        $.each(mPara, function(v,data) {
        	if (flag==1){
        		_1[v]=encodeURIComponent($DynFun.replaceCalcContent(sandbox, oneCmd,data.toString(), 0));
        	}else{
        		_1[v]=$DynFun.replaceCalcContent(sandbox, oneCmd,data.toString(), 0);
        	}
        	
        });
        return _1;
    },
        _2a = function(sandbox, oneCmd, RefreshObj, logHead) {
            var _1 = oneCmd.C.c;
            if (_1.url==undefined){
                $PublicFun.err("_2a",logHead+" Call WebService 格式错误："+_1);
                setReturnValue(sandbox, oneCmd,-1, RefreshObj, logHead);
            }
            var postFlag=0;
            if (_1.url.substring(0, 2)=="#P"){
            	postFlag=1;	_1.url=_1.url.substring(2);
            }
            var mParaObj = _1a(sandbox, oneCmd,_1.para,postFlag);
            mParaObj["URL"] =$DynFun.replaceCalcContent(sandbox, oneCmd, _1.url, 0); 
            mParaObj["db"] =_1.db; 
            mParaObj["token"] = sandbox.$token; 
            mParaObj["dbs"] = _1a(sandbox, oneCmd,_1.dbs);
            var mResult = $F.ajaxSync("TransWebCall", mParaObj, sandbox.$digest);
            if (mResult) {
            	if (mResult.code > -1) {
            		setReturnValue(sandbox, oneCmd, mResult.value, RefreshObj, logHead);
            	} else {
            		$PublicFun.err("_2a", logHead + " Call WebService 同步:" + mResult.message);
            		setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
            	}
            } else {
            	$PublicFun.err("_2a", logHead + " Call WebService 同步,异常未知错误");
            	setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
            }
            return 1;
        },
        _3a = function(sandbox, oneCmd, RefreshObj, logHead) {
            var _1 = oneCmd.C.c;
            if (_1.url==undefined){
            	$PublicFun.err("_3a",logHead+" Call WebService 格式错误："+_1);
            	setReturnValue(sandbox, oneCmd,-1, RefreshObj, logHead);
            }
            var mCallCmd=_1.cmd;
            var postFlag=0;
            if (_1.url.substring(0, 2)=="#P"){
            	postFlag=1;	_1.url=_1.url.substring(2);
            }
            var mParaObj = _1a(sandbox, oneCmd,_1.para,postFlag);        
            mParaObj["URL"] =$DynFun.replaceCalcContent(sandbox, oneCmd, _1.url, 0);       
            mParaObj["db"] = _1.db;         
            mParaObj["token"] =  sandbox.$token;       
            mParaObj["dbs"] = _1a(sandbox, oneCmd,_1.dbs); 
            $F.ajaxAsync("TransWebCall", mParaObj, function(dataInfo) {
            	if (mCallCmd) {$PublicFun.log("Call WebService 异步", "返回结果:" + JSON.stringify(dataInfo));   // HTTPSUCC,HTTPRESULT
                    if (dataInfo) {if (dataInfo.code > -1) {sandbox.R["HTTPSUCC"] = 1;sandbox.R["HTTPRESULT"] = dataInfo.value;} else {
                            sandbox.R["HTTPSUCC"] = -1;sandbox.R["HTTPRESULT"] = dataInfo.message;
                        }
                    } else {
                        sandbox.R["HTTPSUCC"] = -1;
                        sandbox.R["HTTPRESULT"] = "未知异常";
                    }
                    doOneCmdList(sandbox, "CallWebService-P" + mCallCmd, sandbox.$dynCmds["P" + mCallCmd]);
                } else {
                    $PublicFun.err("_3a", logHead + "Call WebService 异步,未定义返回命令:" + JSON.stringify(dataInfo));
                }
            }, sandbox.$project.digest);
            setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
        },
        doType5_2_BuildPara = function(sandbox, oneCmd, mPara) {
		var mParaStr = "";
		if (mPara) {
			var iTmpIndex = mPara.indexOf("**");
			while (iTmpIndex > -1) {
				var mTmpStr = mPara.substring(0, iTmpIndex);
				mPara = mPara.substring(iTmpIndex + 2);
				var mTmpSubIndex = mTmpStr.indexOf("=");
				if (mTmpSubIndex > -1) {
					mParaStr += "&" + mTmpStr.substring(0, mTmpSubIndex) + "=" + encodeURIComponent($DynFun.replaceCalcContent(sandbox, oneCmd, mTmpStr.substring(mTmpSubIndex + 1), 0));
				}
				iTmpIndex = mPara.indexOf("**");
			}
			if (mPara.trim()) {
				var mTmpSubIndex = mPara.indexOf("=");
				if (mTmpSubIndex > -1) {
					mParaStr += "&" + mPara.substring(0, mTmpSubIndex) + "=" + encodeURIComponent($DynFun.replaceCalcContent(sandbox, oneCmd, mPara.substring(mTmpSubIndex + 1), 0));
				}
			}
		}
		if (mParaStr.length > 0) {
			return mParaStr.substring(1);
		} else {
			return "";
		}
	},doType5_2NewBuild= function(sandbox, oneCmd, mPara) {
				var mParaStr = "";
				$.each(mPara, function(v,data) {
					mParaStr += "&" + v + "=" + encodeURIComponent($DynFun.replaceCalcContent(sandbox, oneCmd,data, 0));
				});
				if (mParaStr.length > 0) {
					return mParaStr.substring(1);
				} else {
					return "";
				}
	},
			doType5_2 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mContent = oneCmd.C.c;
		if (mContent.url==undefined){$PublicFun.err("doType5_2",logHead+" pt 格式错误："+mContent);}
 		var mURL=mContent.url, mPara=mContent.para, mCharset=mContent.cset;
		mURL = $DynFun.replaceCalcContent(sandbox, oneCmd, mURL, 0);
		mPara = doType5_2NewBuild(sandbox, oneCmd, mPara);
		var mParaObj = {};
		mParaObj["URL"] = mURL;
		mParaObj["Method"] = "POST";
		mParaObj["Content"] = mPara;
		mParaObj["chrset"] = mCharset;
		mParaObj["db"]=mContent.db;
		mParaObj["token"] = sandbox.$token; 
		mParaObj["dbs"] = _1a(sandbox, oneCmd,mContent.dbs);
		var mResult = $F.ajaxSync("HttpRequest", mParaObj, sandbox.$digest);
		if (mResult) {
			if (mResult.code > -1) {
				setReturnValue(sandbox, oneCmd, mResult.value, RefreshObj, logHead);
			} else {
				$PublicFun.err("doType5_2", logHead + " Call POST 同步:" + mResult.message);
				setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
			}
		} else {
			$PublicFun.err("doType5_2", logHead + " Call POST 同步,异常未知错误");
			setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
		}
		return 1;
	}, doType5_3 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mContent = oneCmd.C.c;
		if (mContent.url==undefined){$PublicFun.err("doType5_3",logHead+" gt 格式错误："+mContent);}
		var mURL=mContent.url, mPara=mContent.para, mCharset=mContent.cset;
		mURL = $DynFun.replaceCalcContent(sandbox, oneCmd, mURL, 0);
		mPara = doType5_2NewBuild(sandbox, oneCmd, mPara);
	 	var mParaObj = {};
		mParaObj["URL"] = mURL;
		mParaObj["Method"] = "GET";
		mParaObj["Content"] = mPara;
		mParaObj["chrset"] = mCharset;
		mParaObj["db"]=mContent.db;
		mParaObj["token"] = sandbox.$token; 
		mParaObj["dbs"] = _1a(sandbox, oneCmd,mContent.dbs);
		var mResult = $F.ajaxSync("HttpRequest", mParaObj, sandbox.$digest);
		if (mResult) {
			if (mResult.code > -1) {
				setReturnValue(sandbox, oneCmd, mResult.value, RefreshObj, logHead);
			} else {
				$PublicFun.err("doType5_3", logHead + " Call GET 同步:" + mResult.message);
				setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
			}
		} else {
			$PublicFun.err("doType5_3", logHead + " Call GET 同步,异常未知错误");
			setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
		}
		return 1;
	}, doType5_4 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mContent = oneCmd.C.c;
		if (mContent.url==undefined){$PublicFun.err("doType5_3",logHead+"a pt 格式错误："+mContent);}
		var mCallCmd=mContent.cmd;
		mCallCmd= $DynFun.replaceCalcContent(sandbox, oneCmd, mCallCmd, 0);
		var mURL=mContent.url, mPara=mContent.para, mCharset=mContent.cset;
		mURL = $DynFun.replaceCalcContent(sandbox, oneCmd, mURL, 0);
		mPara = doType5_2NewBuild(sandbox, oneCmd, mPara);
		var mParaObj = {};
		mParaObj["URL"] = mURL;
		mParaObj["Method"] = "POST";
		mParaObj["Content"] = mPara;
		mParaObj["chrset"] = mCharset;
		mParaObj["db"]=mContent.db;
		mParaObj["token"] = sandbox.$token; 
		mParaObj["dbs"] = _1a(sandbox, oneCmd,mContent.dbs);
		$F.ajaxAsync("HttpRequest", mParaObj, function(dataInfo) {
			if (mCallCmd) {
				$PublicFun.log("doType5_4", logHead + " Call Post 异步,返回结果:" + JSON.stringify(dataInfo));
				// HTTPSUCC,HTTPRESULT
				if (dataInfo) {
					if (dataInfo.code > -1) {
						sandbox.R["HTTPSUCC"] = 1;
						sandbox.R["HTTPRESULT"] = dataInfo.value;
					} else {
						sandbox.R["HTTPSUCC"] = -1;
						sandbox.R["HTTPRESULT"] = dataInfo.message;
					}
				} else {
					sandbox.R["HTTPSUCC"] = -1;
					sandbox.R["HTTPRESULT"] = "未知异常";
				}
				doOneCmdList(sandbox, "Post-P" + mCallCmd, sandbox.$dynCmds["P" + mCallCmd]);
			} else {
				$PublicFun.err("doType5_4", logHead + " Call Post 异步,未定义返回命令:" + JSON.stringify(dataInfo));
			}
		}, sandbox.$project.digest);
		setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
		return 1;
	}, doType5_5 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mContent = oneCmd.C.c;
		if (mContent.url==undefined){$PublicFun.err("doType5_5",logHead+" a gt 格式错误："+mContent);}
		var mCallCmd=mContent.cmd;
		mCallCmd= $DynFun.replaceCalcContent(sandbox, oneCmd, mCallCmd, 0);
		var mURL=mContent.url, mPara=mContent.para, mCharset=mContent.cset;
		mURL = $DynFun.replaceCalcContent(sandbox, oneCmd, mURL, 0);
		mPara = doType5_2NewBuild(sandbox, oneCmd, mPara);
		var mParaObj = {};
		mParaObj["URL"] = mURL;
		mParaObj["Method"] = "GET";
		mParaObj["Content"] = mPara;
		mParaObj["chrset"] = mCharset;
		mParaObj["db"]=mContent.db;
		mParaObj["token"] = sandbox.$token; 
		mParaObj["dbs"] = _1a(sandbox, oneCmd,mContent.dbs);
		$F.ajaxAsync("HttpRequest", mParaObj, function(dataInfo) {
			if (mCallCmd) {
				$PublicFun.log("Call GET 异步", "返回结果:" + JSON.stringify(dataInfo));
				// HTTPSUCC,HTTPRESULT
				if (dataInfo) {
					if (dataInfo.code > -1) {
						sandbox.R["HTTPSUCC"] = 1;
						sandbox.R["HTTPRESULT"] = dataInfo.value;
					} else {
						sandbox.R["HTTPSUCC"] = -1;
						sandbox.R["HTTPRESULT"] = dataInfo.message;
					}
				} else {
					sandbox.R["HTTPSUCC"] = -1;
					sandbox.R["HTTPRESULT"] = "未知异常";
				}
				doOneCmdList(sandbox, "GET-P" + mCallCmd, sandbox.$dynCmds["P" + mCallCmd]);
			} else {
				$PublicFun.err("doType5_5", logHead + " Call GET 异步,未定义返回命令:" + JSON.stringify(dataInfo));
			}
		}, sandbox.$project.digest);
		setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
		return 1;
	}, doType5_6 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mContent = oneCmd.C.c;
		mContent = $DynFun.replaceCalcContent(sandbox, oneCmd, mContent, 0);
		var mParaObj = {};
		mParaObj["XML"] = mContent;
		var mResult = $F.ajaxSync("XMLConvert", mParaObj, sandbox.$digest, {token:sandbox.$token});
		if (mResult) {
			if (mResult.code > -1) {
				mContent = mResult.value;
				$PublicFun.log("doType5_6", logHead + " XML Convert:", mContent);
				var mXMLCls = new $PublicFun.$LIB.OXML(mContent);
				mXMLCls.loadxml();
				if (mXMLCls.flag == 1) {
					$PublicFun.$GX.xmlProcess = mXMLCls;
					return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
				} else {
					$PublicFun.$GX.xmlProcess = null;
					return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
				}
			} else {
				$PublicFun.err("doType5_6", logHead + " XML Convert 失败,XML Convert 失败");
				$PublicFun.$GX.xmlProcess = null;
				return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			}
		} else {
			$PublicFun.err("doType5_6", logHead + " XML Convert 失败,XML Convert 失败");
			$PublicFun.$GX.xmlProcess = null;
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}


	}, doType5_7 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mContent = oneCmd.C.c;
		mContent = $DynFun.replaceCalcContent(sandbox, oneCmd, mContent, 0);
		var mXMLCls = new $PublicFun.$LIB.OXML(mContent);
		mXMLCls.loadxml();
		if (mXMLCls.flag == 1) {
			$PublicFun.$GX.xmlProcess = mXMLCls;
			return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
		} else {
			$PublicFun.$GX.xmlProcess = null;
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
	}, doType5_8 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mContent = oneCmd.C.c;
		mContent = $DynFun.replaceCalcContent(sandbox, oneCmd, mContent, 0);
		mContent = encodeURIComponent(mContent);
		return setReturnValue(sandbox, oneCmd, mContent, RefreshObj, logHead);
	}, doType5_9 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mContent = oneCmd.C.c;
		mContent = $DynFun.replaceCalcContent(sandbox, oneCmd, mContent, 0);
		if ($PublicFun.$GX.xmlProcess == null) {
			return setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
		} else {
			var mResult = $PublicFun.$GX.xmlProcess.getOne(mContent);
			return setReturnValue(sandbox, oneCmd, mResult, RefreshObj, logHead);
		}
	}, doType5_10 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mContent = oneCmd.C.c;
		mContent = $DynFun.replaceCalcContent(sandbox, oneCmd, mContent, 0).trim();
		if ($PublicFun.$GX.xmlProcess == null) {
			return setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
		} else {
			if (mContent.substring(0, 1) == "^") {
				mContent = mContent.substring(1);
				var mResult = $PublicFun.$GX.xmlProcess.getCircleList(mContent);
				return setReturnValue(sandbox, oneCmd, mResult, RefreshObj, logHead);
			} else {
				var mResult = $PublicFun.$GX.xmlProcess.getList(mContent);
				return setReturnValue(sandbox, oneCmd, mResult, RefreshObj, logHead);
			}
		}
	}, doType5_11 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mContent = oneCmd.C.c;
		mContent = $DynFun.replaceCalcContent(sandbox, oneCmd, mContent, 0);
		if ($PublicFun.$GX.xmlProcess == null) {
			return setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
		} else {
			var mResult = $PublicFun.$GX.xmlProcess.getCircleList(mContent);
			return setReturnValue(sandbox, oneCmd, mResult, RefreshObj, logHead);
		}
	}, doType5_12 = function(sandbox, oneCmd, RefreshObj, logHead) {
		//JSON解析相关命令已废弃
		var mContent = oneCmd.C.c;
		mContent = $DynFun.replaceCalcContent(sandbox, oneCmd, mContent, 0);
		var mJSONPro = new $PublicFun.$LIB.OJSON(mContent);
		mJSONPro.LoadJSON();
		if (mJSONPro.flag == 1) {
			$PublicFun.log("JSON String", mContent);
			$PublicFun.$GJ.JSONProcess = mJSONPro;
			return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
		} else {
			$PublicFun.$GJ.JSONProcess = null;
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
	}, doType5_13 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mContent = oneCmd.C.c;
		mContent = $DynFun.replaceCalcContent(sandbox, oneCmd, mContent, 0);
		if ($PublicFun.$GJ.JSONProcess == null) {
			return setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
		} else {
			var mResult = $PublicFun.$GJ.JSONProcess.getOne(mContent);
			return setReturnValue(sandbox, oneCmd, mResult, RefreshObj, logHead);
		}
	}, doType5_14 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mContent = oneCmd.C.c;
		mContent = $DynFun.replaceCalcContent(sandbox, oneCmd, mContent, 0).trim();
		if ($PublicFun.$GJ.JSONProcess == null) {
			return setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
		} else {
			var mResult = $PublicFun.$GJ.JSONProcess.getList(mContent);
			return setReturnValue(sandbox, oneCmd, mResult, RefreshObj, logHead);
		}
	}, doType5_15 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mContent = oneCmd.C.c;
		mContent = $DynFun.replaceCalcContent(sandbox, oneCmd, mContent, 0).trim();
		var mArr = $PublicFun.stringToArray(mContent, "|*|");
		var mPara = {
			token : sandbox.$token,
			dbPool : ""
		};
		if (mArr.length > 0) {
			mPara["clsName"] = mArr[0];
		}
		for (var i = 1; i < mArr.length; i++) {
			mPara["O" + i] = mArr[i];
		}
		var mRs = $F.ajaxSync("JSGenerateServlet", mPara, sandbox.$digest);
		if (mRs) {
			if (mRs.code < 0) {
				$PublicFun.err("doType5_15", logHead + " JSGenerateServlet Failed:" + mRs.message);
				setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
			} else {
				var marr = [ mRs.code, mRs.value, mRs.message ];
				setReturnValue(sandbox, oneCmd, marr, RefreshObj, logHead);
			}
		} else {
			$PublicFun.err("doTyp5_15", logHead + " JSGenerateServlet   Failed Unknow Error");
			setReturnValue(sandbox, oneCmd, "", RefreshObj, logHead);
		}
		return 1;
	},

	doType5 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C
		switch (content.t) {
		case 0:// CALLSV
			return _2a(sandbox, oneCmd, RefreshObj, logHead);
		case 1:// CALLAS
			return _3a(sandbox, oneCmd, RefreshObj, logHead);
		case 2:// CALLPT
			return doType5_2(sandbox, oneCmd, RefreshObj, logHead);
		case 3:// CALLGT
			return doType5_3(sandbox, oneCmd, RefreshObj, logHead);
		case 4:// ANSYPT
			return doType5_4(sandbox, oneCmd, RefreshObj, logHead);
		case 5:// ANSYGT
			return doType5_5(sandbox, oneCmd, RefreshObj, logHead);
		case 6:// SETCML
			return doType5_6(sandbox, oneCmd, RefreshObj, logHead);
		case 7:// SETXML
			return doType5_7(sandbox, oneCmd, RefreshObj, logHead);
		case 8:// STUTF8
			return doType5_8(sandbox, oneCmd, RefreshObj, logHead);
		case 9:// GETONE
			return doType5_9(sandbox, oneCmd, RefreshObj, logHead);
		case 10:// GETLST
			return doType5_10(sandbox, oneCmd, RefreshObj, logHead);
		case 11:// Circle GetList
			return doType5_11(sandbox, oneCmd, RefreshObj, logHead);
		case 12:// SETJSO
			return doType5_12(sandbox, oneCmd, RefreshObj, logHead);
		case 13:// GETJON
			return doType5_13(sandbox, oneCmd, RefreshObj, logHead);
		case 14:// GETJLS
			return doType5_14(sandbox, oneCmd, RefreshObj, logHead);
		case 15:// GENERL //通用CALL
			return doType5_15(sandbox, oneCmd, RefreshObj, logHead);
		case -1:// 未知
		}
	},
	/**
	 * @method doType35
	 */
	doType35 = function(sandbox, oneCmd, RefreshObj, logHead) {
		// console.log(oneCmd);
		var content = oneCmd.C
		switch (content.t) {
		case 1: // 获取表格行数
			return doType35_1(sandbox, oneCmd, RefreshObj, logHead);
		case 2: // 编辑表格数据
			return doType35_2(sandbox, oneCmd, RefreshObj, logHead);
		case 3: // 获取一行值
			return doType35_3(sandbox, oneCmd, RefreshObj, logHead);
		case 4: // 删除一行数据
			return doType35_4(sandbox, oneCmd, RefreshObj, logHead);
		case 5: // 刷新表格
			return doType35_5(sandbox, oneCmd, RefreshObj, logHead);
		case 6: // 保存数据---单记录保存
			return doType35_6(sandbox, oneCmd, RefreshObj, logHead, 0);
		case 7: // 保存数据---单记录保存(到缓存)
			return doType35_6(sandbox, oneCmd, RefreshObj, logHead, 1);
		case 8: // 删除数据
			return doType35_8(sandbox, oneCmd, RefreshObj, logHead, 0);
		case 9: // 删除数据（到缓存）
			return doType35_8(sandbox, oneCmd, RefreshObj, logHead, 1);
		case 10: // 表格保存
			return doType35_10(sandbox, oneCmd, RefreshObj, logHead, 0);
		case 11: // 表格保存到缓存
			return doType35_10(sandbox, oneCmd, RefreshObj, logHead, 1);
		case 12: // 编辑表保存
			return doType35_12(sandbox, oneCmd, RefreshObj, logHead, 0, 1);
		case 13: // 编辑表保存到缓存
			return doType35_12(sandbox, oneCmd, RefreshObj, logHead, 1, 1);
		case 14: // 提交缓存
			return doType35_14(sandbox, oneCmd, RefreshObj, logHead);
		case 15: // 清除缓存
			return doType35_15(sandbox, oneCmd, RefreshObj, logHead);
		case 16: // 交叉表
			// doType35_16=function(sandbox,oneCmd,RefreshObj,logHead,iFlag,iF2){
			return doType35_16(sandbox, oneCmd, RefreshObj, logHead, 0, 0)
		case 17: // 交叉表
			return doType35_16(sandbox, oneCmd, RefreshObj, logHead, 1, 0)
		case 18: // 交叉表
			return doType35_16(sandbox, oneCmd, RefreshObj, logHead, 0, 1, 1)
		case 19: // 交叉表
			return doType35_16(sandbox, oneCmd, RefreshObj, logHead, 1, 1, 1)
		case 20: // 编辑表只保存修改新增到数据库
			return doType35_12(sandbox, oneCmd, RefreshObj, logHead, 0, 0);
		case 21: // 编辑表只保存修改新增到缓存
			return doType35_12(sandbox, oneCmd, RefreshObj, logHead, 1, 0);
		case 22: // 交叉表只保存修改新增到数据库
			return doType35_16(sandbox, oneCmd, RefreshObj, logHead, 0, 1, 0)
		case 23: // 交叉表只保存修改新增到缓存
			return doType35_16(sandbox, oneCmd, RefreshObj, logHead, 1, 1, 0)
		default:
			$PublicFun.err("doType35", logHead + " 未找到对应命令:" + content);
			return 1;
		}
	}, doType35_SetFieldKeyGrid = function(vboundData, keyArr, RowData) {
		var iCount = keyArr.length;
		for (var i = 0; i < iCount; i++) {
			var mOne = keyArr[i];
			vboundData.KeyInfoEdit(mOne.f);
			if (mOne.a == 0) {
				vboundData.NewValueEdit(mOne.f, mOne.v, mOne.t);
			} else {
				if (mOne.v > RowData.length || mOne.v < 0) {
					vboundData.NewValueEdit(mOne.f, "", mOne.t);
				} else {
					vboundData.NewValueEdit(mOne.f, RowData[mOne.v] == undefined ? "" : RowData[mOne.v], mOne.t);
				}
			}
		}
	}, doType35_SetFieldGrid = function(vboundData, FieldArr, RowData) {
		var iCount = FieldArr.length;
		for (var i = 0; i < iCount; i++) {
			var mOne = FieldArr[i];
			if (mOne.a == 0) {
				vboundData.NewValueEdit(mOne.f, mOne.v, mOne.t);
			} else {
				if (mOne.v > RowData.length || mOne.v < 0) {
					vboundData.NewValueEdit(mOne.f, "", mOne.t);
				} else {
					vboundData.NewValueEdit(mOne.f, RowData[mOne.v] == undefined ? "" : RowData[mOne.v], mOne.t);
				}
			}
		}
	},

	doType35_MustVaild = function(boundInfo, mustArr) {
		var iCount = mustArr.length;
		for (var i = 0; i < iCount; i++) {
			var mTmp = boundInfo.getValue(mustArr[i]);
			if (mTmp == "") {
				return -1;
			}
		}
		return 1;
	}, doType35_AddOneRow = function(tbName, keyFlag, rootBound, keyArr, FieldArr, MustArr, OneRowData, i) {
		var mTmpBound = new BoundData(tbName);
		if (keyFlag == 0) {
			mTmpBound.notFindDupli = 1;
		}
		doType35_SetFieldKeyGrid(mTmpBound, keyArr, OneRowData);
		doType35_SetFieldGrid(mTmpBound, FieldArr, OneRowData);
		if (doType35_MustVaild(mTmpBound, MustArr) > 0) {
			rootBound.SubTableAdd("F" + i, mTmpBound);
		}
	}, doType35_DelOneRow = function(tbName, keyFlag, rootBound, keyArr, OneRowData, i) {
		var mTmpBound = new BoundData(tbName);
		mTmpBound.deleteFlag = 1;
		doType35_SetFieldKeyGrid(mTmpBound, keyArr, OneRowData);
		rootBound.SubTableAdd("DD" + i, mTmpBound);
	}, doType35_10_1_1 = function(sandbox, item) {
		var mObj = {};
		mObj.f = item.f;
		mObj.t = item.t;
		mObj.v = $DynFun.replaceVarValue(sandbox, item.v.r, item.v.c, 0);
		mObj.a = 0;
		if (mObj.v.length > 4) {
			if (mObj.v.substring(0, 4).toUpperCase() == "COL#") {
				mObj.a = 1;
				mObj.v = $PublicFun.stringToInt(mObj.v.substring(4).trim()) - 1;
				// }else if (mObj.v.substring(0,4).toUpperCase()=="TRA#"){
				// mObj.a=2;
				// mObj.v=$PublicFun.stringToInt (mObj.v.substring(4).trim())-1;
			}
		}
		return mObj;
	}, doType35_10_1 = function(sandbox, inObj) {
		var mReturn = [];
		if (inObj) {
			var iCount = inObj.length;
			for (var i = 0; i < iCount; i++) {
				var mOne = inObj[i];
				mReturn[i] = doType35_10_1_1(sandbox, mOne);
			}
		}
		return mReturn;
	}, doType35_10 = function(sandbox, oneCmd, RefreshObj, logHead, iFlag) {
		var mEditObj = oneCmd.C.c;
		// console.log(mEditObj) ;
		var mDBPool = $DynFun.replaceVarValue(sandbox, mEditObj.dbpool.r, mEditObj.dbpool.c, 0).trim();
		var mTBName = $DynFun.replaceVarValue(sandbox, mEditObj.tbName.r, mEditObj.tbName.c, 0).trim();
		var mGridName = $DynFun.replaceVarValue(sandbox, mEditObj.gridName.r, mEditObj.gridName.c, 0).trim();
		var mKeyObj = mEditObj.keyList;
		var mFKeyObj = mEditObj.fkeyList;
		var mFieldList = mEditObj.fieldList;
		var mMustList = mEditObj.must;
		var mRootBound = new BoundData(mTBName);
		var mKeyFlag = 0;
		if (mKeyObj.length <= 0) {// 无主键
			mRootBound.deleteFlag = 1;
			mKeyFlag = 0;
			doType35_SetFieldKey(sandbox, mRootBound, mFKeyObj);
		} else {
			mRootBound.notOperateRec = 1;
			mKeyFlag = 1;
		}
		var mOneVar = sandbox.getOneVarStruct(mGridName.toLowerCase());
		if (mOneVar == undefined) {
			$PublicFun.err("doType35_10", logHead + " 未找到对应变量:" + mGridName + " Express:" + JSON.stringify(oneCmd.C.c));
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		} else {
			if (mOneVar.VT == 4) {
				var mValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
				if (mValue instanceof Array) {
					var mKeyArr;
					if (mKeyFlag == 0) {
						mKeyArr = doType35_10_1(sandbox, mFKeyObj);
					} else {
						mKeyArr = doType35_10_1(sandbox, mKeyObj);
					}
					var mFieldArr;
					mFieldArr = doType35_10_1(sandbox, mFieldList);
					// var mMustList=mEditObj.must;
					var iCount = mValue.length;
					for (var i = 0; i < iCount; i++) {
						var mOneRow = mValue[i];
						doType35_AddOneRow(mTBName, mKeyFlag, mRootBound, mKeyArr, mFieldArr, mMustList, mOneRow, i);
					}
				}
				if (iFlag == 0) {
					var mRs = $F.ajaxSync("SystemDo5", {
						token : sandbox.$token,
						dbPool : mDBPool,
						xml : mRootBound.getData()
					}, sandbox.$digest);
					if (mRs) {
						return setReturnValue(sandbox, oneCmd, mRs.code, RefreshObj, logHead);
					} else {
						return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
					}
				} else {
					sandbox.$instance.$JETC[$PublicFun.newGuid()] = mRootBound;
					return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
				}
			} else {
				$PublicFun.err("doType35_10", logHead + " 对应变量:" + mGridName + " 非表格变量 Express:" + JSON.stringify(oneCmd.C.c));
				return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			}
		}
	}, doType35_16_1_1 = function(sandbox, item) {
		var mReturnObj = {};
		var mTransIndex = -1;
		var mObj = {};
		mObj.f = item.f;
		mObj.t = item.t;
		mObj.v = $DynFun.replaceVarValue(sandbox, item.v.r, item.v.c, 0);
		mObj.a = 0;
		if (mObj.v.length > 4) {
			if (mObj.v.substring(0, 4).toUpperCase() == "COL#") {
				mObj.a = 1;
				mObj.v = $PublicFun.stringToInt(mObj.v.substring(4).trim()) - 1;
			} else if (mObj.v.substring(0, 4).toUpperCase() == "TRA#") {
				mObj.a = 2;
				mReturnObj["T"] = $PublicFun.stringToInt(mObj.v.substring(4).trim()) - 1;
			} else if (mObj.v.substring(0, 4).toUpperCase() == "TRV#") {
				mObj.a = 3;
				mReturnObj["TV"] = 1;
			}
		} else if (mObj.v.toUpperCase() == "TRV#") {
			mObj.a = 3;
			mReturnObj["TV"] = 1;
		}
		mReturnObj["V"] = mObj;
		return mReturnObj;
	}, doType35_16_1 = function(sandbox, inObj) {
		var mResult = {};
		var mReturn = [];
		if (inObj) {
			var iCount = inObj.length;
			for (var i = 0; i < iCount; i++) {
				var mOne = inObj[i];
				var mTmpObj = doType35_16_1_1(sandbox, mOne);
				if (mTmpObj["T"] > -1) {
					mResult["T"] = mTmpObj["T"];
				}
				if (mTmpObj["TV"] == 1) {
					mResult["TV"] = mTmpObj["TV"];
				}
				mReturn[i] = mTmpObj["V"];
			}
		}
		mResult["V"] = mReturn;
		return mResult;
	}, doType35_16_AddOneRow_1 = function(tbName, keyFlag, rootBound, keyArr, FieldArr, MustArr, OneRowData, transKey, transValue) {
		var mTmpBound = new BoundData(tbName);
		if (keyFlag == 0) {
			mTmpBound.notFindDupli = 1;
		}
		doType35_16_SetFieldKeyGrid(mTmpBound, keyArr, OneRowData, transKey, transValue);
		doType35_16_SetFieldGrid(mTmpBound, FieldArr, OneRowData, transKey, transValue);
		if (doType35_MustVaild(mTmpBound, MustArr) > 0) {
			rootBound.SubTableAdd($PublicFun.newGuid(), mTmpBound);
		}
	}, doType35_16_AddOneRow = function(firstRow, BTCol, tbName, keyFlag, rootBound, keyArr, FieldArr, MustArr, OneRowData) {
		var iCount = OneRowData.length;
		for (var i = BTCol; i < iCount; i++) {
			var mTmpKey = firstRow[i];
			if (OneRowData[i]) {
				var mTmpValue = OneRowData[i] == undefined ? "" : OneRowData[i];
				doType35_16_AddOneRow_1(tbName, keyFlag, rootBound, keyArr, FieldArr, MustArr, OneRowData, mTmpKey, mTmpValue);
			}
		}
	},

	doType35_16_DelOneRow = function(tbName, keyFlag, rootBound, keyArr, OneRowData) {
		var mTmpBound = new BoundData(tbName);
		mTmpBound.deleteFlag = 1;
		doType35_16_SetFieldKeyGrid_Del(mTmpBound, keyArr, OneRowData);
		rootBound.SubTableAdd($PublicFun.newGuid(), mTmpBound);
	},

	doType35_16_SetFieldGrid = function(vboundData, FieldArr, RowData, TransKey, TransValue) {
		var iCount = FieldArr.length;
		for (var i = 0; i < iCount; i++) {
			var mOne = FieldArr[i];
			if (mOne.a == 0) {
				vboundData.NewValueEdit(mOne.f, mOne.v, mOne.t);
			} else if (mOne.a == 2) {
				vboundData.NewValueEdit(mOne.f, TransKey, mOne.t);
			} else if (mOne.a == 3) {
				vboundData.NewValueEdit(mOne.f, TransValue, mOne.t);
			} else {
				if (mOne.v > RowData.length || mOne.v < 0) {
					vboundData.NewValueEdit(mOne.f, "", mOne.t);
				} else {
					vboundData.NewValueEdit(mOne.f, RowData[mOne.v] == undefined ? "" : RowData[mOne.v], mOne.t);
				}
			}
		}
	}, doType35_16_SetFieldKeyGrid = function(vboundData, keyArr, RowData, TransKey, TransValue) {
		var iCount = keyArr.length;
		for (var i = 0; i < iCount; i++) {
			var mOne = keyArr[i];
			vboundData.KeyInfoEdit(mOne.f);
			if (mOne.a == 0) {
				vboundData.NewValueEdit(mOne.f, mOne.v, mOne.t);
			} else if (mOne.a == 2) {
				vboundData.NewValueEdit(mOne.f, TransKey, mOne.t);
			} else if (mOne.a == 3) {
				vboundData.NewValueEdit(mOne.f, TransValue, mOne.t);
			} else {
				if (mOne.v > RowData.length || mOne.v < 0) {
					vboundData.NewValueEdit(mOne.f, "", mOne.t);
				} else {
					vboundData.NewValueEdit(mOne.f, RowData[mOne.v] == undefined ? "" : RowData[mOne.v], mOne.t);
				}
			}
		}
	}, doType35_16_SetFieldKeyGrid_Del = function(vboundData, keyArr, RowData, TransKey, TransValue) {
		var iCount = keyArr.length;
		for (var i = 0; i < iCount; i++) {
			var mOne = keyArr[i];
			if (One.a == 2 || One.a == 3) {
			} else {
				vboundData.KeyInfoEdit(mOne.f);
				if (mOne.a == 0) {
					vboundData.OldValue(mOne.f, mOne.v, mOne.t);
				} else {
					if (mOne.v > RowData.length || mOne.v < 0) {
						vboundData.OldValue(mOne.f, "", mOne.t);
					} else {
						vboundData.OldValue(mOne.f, RowData[mOne.v] == undefined ? "" : RowData[mOne.v], mOne.t);
					}
				}
			}
		}
	}, doType35_16 = function(sandbox, oneCmd, RefreshObj, logHead, iFlag, iF2, NormalAddFlag) {
		var mEditObj = oneCmd.C.c;
		var mDBPool = $DynFun.replaceVarValue(sandbox, mEditObj.dbpool.r, mEditObj.dbpool.c, 0).trim();
		var mTBName = $DynFun.replaceVarValue(sandbox, mEditObj.tbName.r, mEditObj.tbName.c, 0).trim();
		var mGridName = $DynFun.replaceVarValue(sandbox, mEditObj.gridName.r, mEditObj.gridName.c, 0).trim();
		var mKeyObj = mEditObj.keyList;
		var mFKeyObj = mEditObj.fkeyList;
		var mFieldList = mEditObj.fieldList;
		var mMustList = mEditObj.must;
		var mRootBound = new BoundData(mTBName);
		var mKeyFlag = 0;
		if (mKeyObj.length <= 0) {// 无主键
			mRootBound.deleteFlag = 1;
			mKeyFlag = 0;
			doType35_SetFieldKey(sandbox, mRootBound, mFKeyObj);
		} else {
			mRootBound.notOperateRec = 1;
			mKeyFlag = 1;
		}
		var mOneVar = sandbox.getOneVarStruct(mGridName.toLowerCase());
		if (mOneVar == undefined) {
			$PublicFun.err("doType35_16", logHead + " 未找到对应变量:" + mGridName + " Express:" + JSON.stringify(oneCmd.C.c));
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		} else {
			if (mOneVar.VT == 4) {
				var mValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
				if (mValue instanceof Array) {
					var mTmpObj, mTransIndex = -1, mTranV = 0;
					var mKeyArr;
					if (mKeyFlag == 0) {
						mTmpObj = doType35_16_1(sandbox, mFKeyObj);
						if (mTmpObj["T"] > -1) {
							mTransIndex = mTmpObj["T"];
						}
						if (mTmpObj["TV"] == 1) {
							mTranV = 1;
						}
						mKeyArr = mTmpObj["V"];
					} else {
						mTmpObj = doType35_16_1(sandbox, mKeyObj);
						if (mTmpObj["T"] > -1) {
							mTransIndex = mTmpObj["T"];
						}
						if (mTmpObj["TV"] == 1) {
							mTranV = 1;
						}
						mKeyArr = mTmpObj["V"];
					}
					var mFieldArr;
					mTmpObj = doType35_16_1(sandbox, mFieldList);
					if (mTmpObj["T"] > -1) {
						mTransIndex = mTmpObj["T"];
					}
					if (mTmpObj["TV"] == 1) {
						mTranV = 1;
					}
					mFieldArr = mTmpObj["V"];
					if (mTransIndex < 0) {
						$PublicFun.err("doType35_16", logHead + " 必须有一个交叉列:" + mGridName + " Express:" + JSON.stringify(oneCmd.C.c));
						return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
					}
					if (mTranV != 1) {
						$PublicFun.err("doType35_16", logHead + " 必须有一个交叉值列:" + mGridName + " Express:" + JSON.stringify(oneCmd.C.c));
						return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
					}
					var iCount = mValue.length;
					var mFirstRow = mValue[0];// 首记录
					if (iF2 == 1) {
						for (var i = 1; i < iCount; i++) {
							var mOneRow = mValue[i];
							if (mKeyFlag == 0) {// 无主键 模式
								if (mOneRow["flag"] == -1 || mOneRow["flag"] == 3) {
								} else {
									doType35_16_AddOneRow(mFirstRow, mTransIndex, mTBName, mKeyFlag, mRootBound, mKeyArr, mFieldArr, mMustList, mOneRow);
								}
							} else {
								if (mOneRow["flag"] == -1) {// 删除记录
									doType35_16_DelOneRow(mTBName, mKeyFlag, mRootBound, mKeyArr, mOneRow);
								} else if (mOneRow["flag"] == 3) {// 忽略记录{
								} else if (mOneRow["flag"] == 0 || mOneRow["flag"] == undefined) {// 忽略记录{
									if (NormalAddFlag == 1) {
										doType35_16_AddOneRow(mFirstRow, mTransIndex, mTBName, mKeyFlag, mRootBound, mKeyArr, mFieldArr, mMustList, mOneRow);
									}
								} else {
									doType35_16_AddOneRow(mFirstRow, mTransIndex, mTBName, mKeyFlag, mRootBound, mKeyArr, mFieldArr, mMustList, mOneRow);
								}
							}
						}
						if (mKeyFlag == 0) {// 无主键 模式
						}else{
							if (mValue.removed){
								iCount = mValue.removed.length;
								for (var i = 0; i < iCount; i++) {
									var mOneRow = mValue.removed[i];
									doType35_16_DelOneRow(mTBName, mKeyFlag, mRootBound, mKeyArr, mOneRow);
								}
							}
						}
						
						
					} else {
						for (var i = 1; i < iCount; i++) {
							var mOneRow = mValue[i];
							doType35_16_AddOneRow(mFirstRow, mTransIndex, mTBName, mKeyFlag, mRootBound, mKeyArr, mFieldArr, mMustList, mOneRow);
						}
					}

				}
				if (iFlag == 0) {
					var mRs = $F.ajaxSync("SystemDo5", {
						token : sandbox.$token,
						dbPool : mDBPool,
						xml : mRootBound.getData()
					}, sandbox.$digest);
					if (mRs) {
						return setReturnValue(sandbox, oneCmd, mRs.code, RefreshObj, logHead);
					} else {
						return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
					}
				} else {
					sandbox.$instance.$JETC[$PublicFun.newGuid()] = mRootBound;
					return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
				}
			} else {
				$PublicFun.err("doType35_16", logHead + " 对应变量:" + mGridName + " 非表格变量 Express:" + JSON.stringify(oneCmd.C.c));
				return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			}
		}
	}, doType35_15 = function(sandbox, oneCmd, RefreshObj, logHead) {
		$PublicFun.log("doType35_15", logHead + "  Clear Cache Data");
		sandbox.$instance.$JETC = {};
		return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
	}, doType35_14 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mDBPool = $DynFun.replaceCalcContent(sandbox, oneCmd, oneCmd.C.c, 0);
		var mTmpBound = new BoundData("noOperate");
		mTmpBound.notOperateRec = 1;
		var mTmpCache = sandbox.$instance.$JETC;
		var iIndex = 1;
		for ( var key in mTmpCache) {
			var mTmp = mTmpCache[key];
			mTmpBound.SubTableAdd("A" + iIndex, mTmp);
			iIndex++;
		}
		var mRs = $F.ajaxSync("SystemDo5", {
			token : sandbox.$token,
			dbPool : mDBPool,
			xml : mTmpBound.getData()
		}, sandbox.$digest);
		if (mRs) {
			sandbox.$instance.$JETC = {};
			return setReturnValue(sandbox, oneCmd, mRs.code, RefreshObj, logHead);
		} else {
			$PublicFun.err("doType35_14", logHead + "提交数据库失败");
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
	}, doType35_12 = function(sandbox, oneCmd, RefreshObj, logHead, iFlag, NormalAddFlag) {
			var mEditObj = oneCmd.C.c;
			//console.log(mEditObj);
			var mDBPool = $DynFun.replaceVarValue(sandbox, mEditObj.dbpool.r, mEditObj.dbpool.c, 0).trim();
			var mTBName = $DynFun.replaceVarValue(sandbox, mEditObj.tbName.r, mEditObj.tbName.c, 0).trim();
			var mGridName = $DynFun.replaceVarValue(sandbox, mEditObj.gridName.r, mEditObj.gridName.c, 0).trim();
			var mKeyObj = mEditObj.keyList;
			var mFKeyObj = mEditObj.fkeyList;
			var mFieldList = mEditObj.fieldList;
			var mMustList = mEditObj.must;
			var mRootBound = new BoundData(mTBName);
			var mKeyFlag = 0;
			if (mKeyObj.length <= 0) {// 无主键
				mRootBound.deleteFlag = 1;
				mKeyFlag = 0;
				doType35_SetFieldKey(sandbox, mRootBound, mFKeyObj);
			} else {
				mRootBound.notOperateRec = 1;
				mKeyFlag = 1;
			}
			var mOneVar = sandbox.getOneVarStruct(mGridName.toLowerCase());
			if (mOneVar == undefined) {
				$PublicFun.err("doType35_10", logHead + " 未找到对应变量:" + mGridName + " Express:" + JSON.stringify(oneCmd.C.c));
				return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			} else {
				if (mOneVar.VT == 4) {
					var mValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
					if (mValue instanceof Array) {
						var mKeyArr;
						if (mKeyFlag == 0) {
							mKeyArr = doType35_10_1(sandbox, mFKeyObj);
						} else {
							mKeyArr = doType35_10_1(sandbox, mKeyObj);
						}
						var mFieldArr;
						mFieldArr = doType35_10_1(sandbox, mFieldList);
						// var mMustList=mEditObj.must;
						var iCount = mValue.length;
						for (var i = 0; i < iCount; i++) {
							var mOneRow = mValue[i];
							if (mKeyFlag == 0) {// 无主键 模式
								if (mOneRow["flag"] == -1 || mOneRow["flag"] == 3) {
								} else {
									doType35_AddOneRow(mTBName, mKeyFlag, mRootBound, mKeyArr, mFieldArr, mMustList, mOneRow, i);
								}
							} else {
								if (mOneRow["flag"] == -1) {// 删除记录 不会进入这里了
									doType35_DelOneRow(mTBName, mKeyFlag, mRootBound, mKeyArr, mOneRow, i)
								} else if (mOneRow["flag"] == 3) {// 忽略记录{
								} else if (mOneRow["flag"] == 0 || mOneRow["flag"] == undefined) {// 忽略记录{
									if (NormalAddFlag == 1) {
										doType35_AddOneRow(mTBName, mKeyFlag, mRootBound, mKeyArr, mFieldArr, mMustList, mOneRow, i);
									}
								} else {
									doType35_AddOneRow(mTBName, mKeyFlag, mRootBound, mKeyArr, mFieldArr, mMustList, mOneRow, i);
								}
							}
							// if (mOneRow["flag"]==-1 ||)
						}
						if (mKeyFlag == 0) {// 无主键 模式
						}else{
							if (mValue.removed){
								iCount = mValue.removed.length;
								for (var i = 0; i < iCount; i++) {
									var mOneRow = mValue.removed[i];
									doType35_DelOneRow(mTBName, mKeyFlag, mRootBound, mKeyArr, mOneRow, i);
								}
							}
						}
					}
					if (iFlag == 0) {
						var mRs = $F.ajaxSync("SystemDo5", {
							token : sandbox.$token,
							dbPool : mDBPool,
							xml : mRootBound.getData()
						}, sandbox.$digest);
						if (mRs) {
							return setReturnValue(sandbox, oneCmd, mRs.code, RefreshObj, logHead);
						} else {
							return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
						}
					} else {
						sandbox.$instance.$JETC[$PublicFun.newGuid()] = mRootBound;
						return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
					}
				} else {
					$PublicFun.log("doType35_10", logHead + " 对应变量:" + mGridName + " 非表格变量 Express:" + JSON.stringify(oneCmd.C.c));
					return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
				}
			}
	}, doType35_8 = function(sandbox, oneCmd, RefreshObj, logHead, iFlag) {
			var mEditObj = oneCmd.C.c;
			// console.log(mEditObj);
			var mDBPool = $DynFun.replaceVarValue(sandbox, mEditObj.dbpool.r, mEditObj.dbpool.c, 0).trim();
			var mTBName = $DynFun.replaceVarValue(sandbox, mEditObj.tbName.r, mEditObj.tbName.c, 0).trim();
			var mKeyObj = mEditObj.keyList;
			if (mKeyObj) {
				var mBoundOne =  new BoundData(mTBName);
				mBoundOne.deleteFlag = 1;
				doType35_SetFieldKey(sandbox, mBoundOne, mKeyObj);
				if (iFlag == 0) {
					var mRs = $F.ajaxSync("SystemDo5", {
						token : sandbox.$token,
						dbPool : mDBPool,
						xml : mBoundOne.getData()
					}, sandbox.$digest);
					if (mRs) {
						return setReturnValue(sandbox, oneCmd, mRs.code, RefreshObj, logHead);
					} else {
						return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
					}
				} else {
					sandbox.$instance.$JETC[$PublicFun.newGuid()] = mBoundOne;
					return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
				}
			} else {
				setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			}
		
	}, doType35_SetFieldKey = function(sandbox, vboundData, vKeyList) {
		var iCount = vKeyList.length;
		for (var i = 0; i < iCount; i++) {
			var mOne = vKeyList[i];
			vboundData.KeyInfoEdit(mOne.f);
			vboundData.OldValue(mOne.f, $DynFun.replaceVarValue(sandbox, mOne.v.r, mOne.v.c, 0), mOne.t);
		}
	}, doType35_SetField = function(sandbox, vboundData, vFieldList) {
		var iCount = vFieldList.length;
		for (var i = 0; i < iCount; i++) {
			var mOne = vFieldList[i];
			vboundData.NewValueEdit(mOne.f, $DynFun.replaceVarValue(sandbox, mOne.v.r, mOne.v.c, 0), mOne.t);
		}
	}, doType35_6 = function(sandbox, oneCmd, RefreshObj, logHead, iFlag) { // Save One
			var mEditObj = oneCmd.C.c;
			var mDBPool = $DynFun.replaceVarValue(sandbox, mEditObj.dbpool.r, mEditObj.dbpool.c, 0).trim();
			var mTBName = $DynFun.replaceVarValue(sandbox, mEditObj.tbName.r, mEditObj.tbName.c, 0).trim();
			var mKeyObj = mEditObj.keyList;
			var mFieldObj = mEditObj.fieldList;
			if (mKeyObj && mFieldObj) {
				var mBoundOne = new BoundData(mTBName);
				doType35_SetFieldKey(sandbox, mBoundOne, mKeyObj);
				doType35_SetField(sandbox, mBoundOne, mFieldObj);
				if (iFlag == 0) {
					var mRs = $F.ajaxSync("SystemDo5", {
						token : sandbox.$token,
						dbPool : mDBPool,
						xml : mBoundOne.getData()
					}, sandbox.$digest);
					if (mRs) {
						return setReturnValue(sandbox, oneCmd, mRs.code, RefreshObj, logHead);
					} else {
						return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
					}
				} else {
					sandbox.$instance.$JETC[$PublicFun.newGuid()] = mBoundOne;
					return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
				}
			} else {
				return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			}
	},
	doType35_5 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mStr = oneCmd.C.c;
		mStr = $DynFun.replaceCalcContent(sandbox, oneCmd, mStr, 0);
		mStr = mStr.replace(/\x0A|\x0D/g, "").replace(" ", "");
		var mOneVar = sandbox.getOneVarStruct(mStr.toLowerCase());
		if (mOneVar == undefined) {
			$PublicFun.err("doType35_5", "刷新表格数据未找到对应变量:" + mStr + " Express:" + oneCmd.C.c);
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		} else {
			if (mOneVar.VT == 4) {
				var mValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
				RefreshObj[mStr.toLowerCase()] = mValue;
				return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
			} else {
				$PublicFun.err("doType35_5", "刷新表格数据对应变量非表格:" + mStr + " Express:" + oneCmd.C.c);
				return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			}
		}
	}, doType35_4 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mStr = oneCmd.C.c;
		mStr = $DynFun.replaceCalcContent(sandbox, oneCmd, mStr, 0);
		mStr = mStr.replace(/\x0A|\x0D/g, "");
		var iIndex = mStr.indexOf("*,*");
		if (iIndex > -1) {
			var mName = mStr.substring(0, iIndex).trim();
			var Row = $PublicFun.stringToInt(mStr.substring(iIndex + 3));
			Row--;
			if (Row < 0) {
				$PublicFun.err("doType35_4", "删除表格单行数据删除行号必须>0  Express:" + oneCmd.C.c);
				return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			}
			var mOneVar = sandbox.getOneVarStruct(mName.toLowerCase());
			if (mOneVar == undefined) {
				$PublicFun.err("doType35_4", "删除表格单行数据未找到对应变量:" + mName + " Express:" + oneCmd.C.c);
				return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			} else {
				if (mOneVar.VT == 4) {
					var mValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
					if (mValue instanceof Array) {
						// Row--;
						if (Row < mValue.length) {
							mValue.splice(Row, 1);
							return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
						} else {
							$PublicFun.err("doType35_4", "删除表格单行数据删除行号大于表格总行数  Express:" + oneCmd.C.c);
							return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
						}
					} else {
						$PublicFun.err("doType35_4", "删除表格单行数据对应变量为空:" + mName + " Express:" + oneCmd.C.c);
						return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
					}
				} else {
					$PublicFun.err("doType35_4", "删除表格单行数据对应变量不是表格数据:" + mName + " Express:" + oneCmd.C.c);
					return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
				}
			}
		} else {
			$PublicFun.err("doType35_4", "删除表格单行数据格式错误 Express:" + mStr);
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
	}, doType35_2 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mEditObj = oneCmd.C.c;
		var mPName = $DynFun.replaceVarValue(sandbox, mEditObj.grid.r, mEditObj.grid.c, 0).trim();
		if (mPName == "") {
			$PublicFun.err("doType35_2", "对应表格变量未定义  Express :" + JSON.stringify(mEditObj));
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
		var mOneVar = sandbox.getOneVarStruct(mPName.toLowerCase());
		if (mOneVar == undefined) {
			$PublicFun.err("doType35_2", "未找到对应变量:" + mPName + " Express:" + JSON.stringify(mEditObj));
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		} else {
			if (mOneVar.VT != 4) {
				$PublicFun.err("doType35_2", "对应变量:" + mPName + " 非表格类型， Express:" + JSON.stringify(mEditObj));
				return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			}
			var mValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
			if (mValue instanceof Array) {
			} else {
				mValue = [];
				$DynFun.setSystemVar(sandbox, mOneVar, mValue);
			}
			// console.log(mValue);
			var mCurRow = $PublicFun.stringToInt($DynFun.replaceVarValue(sandbox, mEditObj.row.r, mEditObj.row.c, 0).trim());
			var mRefreshFlag = $PublicFun.stringToInt($DynFun.replaceVarValue(sandbox, mEditObj.Refresh.r, mEditObj.Refresh.c, 0).trim());
			if (mCurRow <= 0) {// new Row
				mCurRow = mValue.length;
				mValue[mCurRow] = [];
			} else {// 更新
				mCurRow--;
				if (mCurRow > mValue.length) {
					mCurRow = mValue.length;
					mValue[mCurRow] = [];
				}
			}
			var mRowOBJ = mValue[mCurRow];
			if (mRowOBJ == undefined) {
				$PublicFun.err("doType35_2", "更新的行不存在：" + (mCurRow + 1));
				return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
			}
			var mFields = mEditObj.editField;
			var iCount = mFields.length;
			for (var i = 0; i < iCount; i++) {
				var mTmpOne = mFields[i];
				var mTmpValue = $DynFun.replaceVarValue(sandbox, mTmpOne.v.r, mTmpOne.v.c, 0);
				mRowOBJ[mTmpOne.c] = mTmpValue;
			}
			if (mRefreshFlag == 1) { // 需维护端新增
				$DynFun.refreshObjCell(RefreshObj, mPName.toLowerCase(), mCurRow, undefined, mRowOBJ);
			}
			return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
		}
	}, doType35_3 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mStr = oneCmd.C.c;
		mStr = $DynFun.replaceCalcContent(sandbox, oneCmd, mStr, 0);
		mStr = mStr.replace(/\x0A|\x0D/g, "").replace(" ", "");
		var mTmpArr = mStr.split(",");
		var mPName, mBRow, mBCol, mECol;
		if (mTmpArr.length > 0) {
			mPName = mTmpArr[0].trim();
		} else {
			$PublicFun.err("doType35_3", "获取表格单行数据格式错误 Express:" + mStr);
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
		if (mTmpArr.length > 1) {
			mBRow = $PublicFun.stringToInt(mTmpArr[1]);
		} else {
			$PublicFun.err("doType35_3", "获取表格单行数据格式错误 Express:" + mStr);
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
		if (mBRow < 1) {
			$PublicFun.err("doType35_3", "获取表格单行数据，行号错误，行号须从1开始 Express:" + mStr);
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		}
		if (mTmpArr.length > 2) {
			mBCol = $PublicFun.stringToInt(mTmpArr[2]);
		} else {
			mBCol = 1;
		}
		mBCol--;
		if (mBCol < 0) {
			mBCol = 0;
		}
		if (mTmpArr.length > 3) {
			mECol = $PublicFun.stringToInt(mTmpArr[3]);
			mECol--;
		} else {
			mECol = -1;// 到结束
		}
		if (mECol < 0) {
			mECol = -1;
		}

		var mOneVar = sandbox.getOneVarStruct(mPName.toLowerCase());
		if (mOneVar == undefined) {
			$PublicFun.err("doType35_3", "未找到对应变量:" + mPName + " Express:" + oneCmd.C.c);
			return setReturnValue(sandbox, oneCmd, [], RefreshObj, logHead);
		} else {
			if (mOneVar.VT == 4) {
				var mValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
				if (mValue instanceof Array) {
					mBRow--;
					if (mValue.length > mBRow) {
						var mTmpOneRow = mValue[mBRow];
						if (mTmpOneRow) {
							if (mBCol == 0 && (mECol == -1 || mECol >= mTmpOneRow.length - 1)) {
								return setReturnValue(sandbox, oneCmd, mTmpOneRow, RefreshObj, logHead);
							} else {
								if (mBCol > mECol && mECol != -1) {
									$PublicFun.err("doType35_3", "起始列大于结束列 Express:" + oneCmd.C.c);
									return setReturnValue(sandbox, oneCmd, [], RefreshObj, logHead);
								} else {
									var mReturnArr = [];
									// mBCol--;
									while (mBCol < mTmpOneRow.length) {
										mReturnArr.push(mTmpOneRow[mBCol]);
										mBCol++;
										if (mBCol >= mECol && mECol != -1) {
											break;
										}
									}
									return setReturnValue(sandbox, oneCmd, mReturnArr, RefreshObj, logHead);
								}
							}
						} else {
							$PublicFun.err("doType35_3", "未找到对应行数据：" + (mBRow + 1) + " Express:" + oneCmd.C.c);
							return setReturnValue(sandbox, oneCmd, [], RefreshObj, logHead);
						}
					} else {
						$PublicFun.err("doType35_3", "未找到对应行记录：" + (mBRow + 1) + " Express:" + oneCmd.C.c);
						return setReturnValue(sandbox, oneCmd, [], RefreshObj, logHead);
					}
				} else {
					return setReturnValue(sandbox, oneCmd, [], RefreshObj, logHead);
				}
			} else {
				return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			}
		}
	}, doType35_1 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var mStr = oneCmd.C.c;
		mStr = $DynFun.replaceCalcContent(sandbox, oneCmd, mStr, 0).trim();
		mStr = mStr.replace(/\x0A|\x0D/g, "").replace(" ", "");
		var mOneVar = sandbox.getOneVarStruct(mStr.toLowerCase());
		if (mOneVar == undefined) {
			$PublicFun.err("doType35_1", "未找到对应变量:" + mStr + " Express:" + oneCmd.C.c);
			return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
		} else {
			if (mOneVar.VT == 4) {
				var mValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
				if (mValue instanceof Array) {
					return setReturnValue(sandbox, oneCmd, mValue.length, RefreshObj, logHead);
				} else {
					return setReturnValue(sandbox, oneCmd, 0, RefreshObj, logHead);
				}
			} else {
				return setReturnValue(sandbox, oneCmd, -1, RefreshObj, logHead);
			}
		}
	}, replaceMdlFilterValue = function(sandbox, RelList, Express) {
		// Rel: Array[1]
		// PName: "TEMP.TEXT"
		// Type: 0
		var iCount = RelList.length;
		for (var i = 0; i < iCount; i++) {
			var mTmp = RelList[i];
			switch (mTmp.Type) {
			case 2:// 局部变量
				var mValue = $DynFun.getLocateValue(sandbox, mTmp.PName);
				Express = $DynFun.replaceStr(Express, "[" + mTmp.PName + "]", mValue, 0);
				break;
			case 0:// 属性变量
				var mOneVar = sandbox.getOneVarStruct(mTmp.PName.toLowerCase());
				if (mOneVar == undefined) {
					$PublicFun.err("replaceMdlFilterValue", "未找到对应变量:" + mTmp.PName + " Express:" + Express);
				} else {
					var mValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
					Express = $DynFun.replaceStr(Express, "[" + mOneVar.pM + "." + mOneVar.pS + "]", mValue, 0);
				}
				break;
			case 1: // 静态全局值替换
				var mValue = $DynFun.getSystemStatic(sandbox, mTmp.PName);
				Express = $DynFun.replaceStr(Express, "[" + mTmp.PName + "]", mValue, 0);
				break;
			case 3: // 两个固定的变量替换
				if (mTmp.PName.toUpperCase() == "SYS.OBJECTIVEID") {
					Express = $DynFun.replaceStr(Express, "[SYS.OBJECTIVEID]", sandbox.$instance.id, 0);
				} else if (mTmp.PName.toUpperCase() == "SYS.GUID") {
					Express = $DynFun.replaceStr(Express, "[SYS.GUID]", $PublicFun.newGuid(), 0);
				}
			}
		}
		return Express;
	}, getMDLFilter = function(sandbox, FilterList) {
		var PInfo = {};
		var iCount = FilterList.length;
		for (var i = 0; i < iCount; i++) {
			var mOne = FilterList[i];
			if (mOne.F) {
				var mTmpV = sandbox.evalValue(replaceMdlFilterValue(sandbox, mOne.Rel, mOne.F));
				if (mTmpV) {
					PInfo[mOne.K] = 1;
				} else {
					PInfo[mOne.K] = 0;
				}
			} else {
				PInfo[mOne.K] = 1;
			}
		}
		return PInfo;
	}, getMDLBPara = function(sandbox, RelList) {
		// B: Array[1]
		// F: "0"
		// N: "C0"
		// P: "TEMP.TEXT"
		var Bd = {};
		var iCount = RelList.length;
		for (var i = 0; i < iCount; i++) {
			var mTmp = RelList[i];
			switch (mTmp.F) {
			case 2:// 局部变量
				var mValue = $DynFun.getLocateValue(sandbox, mTmp.P);
				Bd[mTmp.N] = mValue;
				break;
			case 0:// 属性变量
				var mOneVar = sandbox.getOneVarStruct(mTmp.P.toLowerCase());
				if (mOneVar == undefined) {
					$PublicFun.err("getMDLBPara", "未找到对应变量:" + mTmp.P);
					Bd[mTmp.N] = "";
				} else {
					var mValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
					Bd[mTmp.N] = mValue;
				}
				break;
			case 1: // 静态全局值替换
				var mValue = $DynFun.getSystemStatic(sandbox, mTmp.P);
				Bd[mTmp.N] = mValue;
				break;
			case 3: // 两个固定的变量替换
				if (mTmp.P.toUpperCase() == "SYS.OBJECTIVEID") {
					Bd[mTmp.N] = sandbox.$instance.id;
				} else if (mTmp.P.toUpperCase() == "SYS.GUID") {
					Bd[mTmp.N] = $PublicFun.newGuid();
				}
				break;
			}
		}
		return Bd;
	}, 
	
	getMDLServerPara = function(sandbox, mdlId) {
		var struct = sandbox.$runtime.struct;
		var mMDL = struct.MDL;
		if (mMDL) {
			var mOneMDL = mMDL[mdlId];
			if (mOneMDL) {
				var mReturnOBJ = {};
				mReturnOBJ["F"] = getMDLFilter(sandbox, mOneMDL.F);
				mReturnOBJ["B"] = getMDLBPara(sandbox, mOneMDL.B);
				return mReturnOBJ;
			} else {
				$PublicFun.err("getMDLServerPara", "未找到对应的模板：" + mdlId);
			}
		} else {
			$PublicFun.err("getMDLServerPara", "未找到对应的模板列表：" + mdlId);
		}
	},doServerF1_0=function(sandbox, OneCmd, RefreshObj, logHead, publicCmdId){
		var mSqlKey= OneCmd.C.k;
		var mRs = $F.ajaxSync("CacheDo2", {
			token : sandbox.$token,
			dbPool : "",
			ps : publicCmdId,
			sqls : [ {
				cacheId : sandbox.$dynId,
				sqlId : OneCmd.C.c,
				para : $DynFun.getServerPara(sandbox, OneCmd, {},mSqlKey)
			} ]
		}, sandbox.$digest);

		if (mRs) {
			if (mRs.code > -1) {
				var tmpV = mRs.value[0];
				if (tmpV) {
					if (tmpV.count > -1) {
						setReturnValue(sandbox, OneCmd, tmpV.fields, RefreshObj, logHead);
					} else {
						$PublicFun.err("doServerF1_0", logHead + "SQL执行失败, SQLID: " + OneCmd.C.c);
						setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
					}
				} else {
					$PublicFun.err("doServerF1_0", logHead + "获取数据失败，没有得到返回数据");
					setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
				}
			} else {
				$PublicFun.err("doServerF1_0", logHead + "获取数据失败，没有得到返回数据:" + mRs.message);
				setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
			}
		} else {
			$PublicFun.err("doServerF1_0", logHead + "获取数据失败，没有得到返回数据,异常错误");
			setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
		}
	} ,doServerF1_1=function(sandbox, OneCmd, RefreshObj, logHead, publicCmdId){
		var mSqlKey= OneCmd.C.k;
		var mRs = $F.ajaxSync("CacheDo1", {
			token : sandbox.$token,
			dbPool : "",
			ps : publicCmdId,
			sqls : [ {
				cacheId : sandbox.$dynId,
				sqlId : OneCmd.C.c,
				para : $DynFun.getServerPara(sandbox, OneCmd, {},mSqlKey)
			} ]
		}, sandbox.$digest);
		if (mRs) {
			setReturnValue(sandbox, OneCmd, mRs.code, RefreshObj, logHead);
			if (mRs.code < 0) {
				$PublicFun.log("doServerF1_1", logHead + " Failed:" + mRs.message);
			}
		} else {
			$PublicFun.err("doServerF1_1", logHead + " Failed Unknow Error");
			setReturnValue(sandbox, OneCmd, -1, RefreshObj, logHead);
		}
	} ,doServerF1_4=function(sandbox, OneCmd, RefreshObj, logHead, publicCmdId){
		var mSqlKey= OneCmd.C.k;
		var mRs = $F.ajaxSync("CacheDo2M", {
			token : sandbox.$token,
			dbPool : "",
			cacheId : sandbox.$dynId,
			ps : publicCmdId,
			sqlId : OneCmd.C.c,
			para :$DynFun.getServerPara(sandbox, OneCmd, {},mSqlKey)
		}, sandbox.$digest);
		if (mRs) {
			if (mRs.code > -1) {
				setReturnValueMSelect(sandbox, OneCmd, mRs.value, RefreshObj, logHead);
			} else {
				$PublicFun.err("doServerF1_4", logHead + "获取数据失败，没有得到返回数据:" + mRs.message);
				setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
			}
		} else {
			$PublicFun.err("doServerF1_4", logHead + "获取数据失败，没有得到返回数据,异常错误");
			setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
		}	
	}, doServerF1 = function(sandbox, OneCmd, RefreshObj, logHead, publicCmdId) {
		var mType = OneCmd.C.t;
		switch (mType) {
		case 0:  
			doServerF1_0(sandbox, OneCmd, RefreshObj, logHead, publicCmdId);
			break;
		case 1:
			doServerF1_1(sandbox, OneCmd, RefreshObj, logHead, publicCmdId);
			break;
		case 2:  
			var mRs = $F.ajaxSync("CacheDo3", {
				token : sandbox.$token,
				dbPool : "",
				ps : publicCmdId,
				cacheId : sandbox.$dynId,
				sqlId : OneCmd.C.c,
				para : $DynFun.getServerPara(sandbox, OneCmd, {})
		 	}, sandbox.$digest);
			if (mRs) {
				if (mRs.code > -1) {
					var tmpV = mRs.value;
					if (tmpV) {
						setReturnValue(sandbox, OneCmd, tmpV, RefreshObj, logHead);
					} else {
						$PublicFun.err("doServerF1", logHead + "获取存储过程数据失败，没有得到返回数据");
						setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
					}
				} else {
					$PublicFun.err("doServerF1", logHead + "获取数据失败，没有得到返回数据:" + mRs.message);
					setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
				}
			} else {
				$PublicFun.err("doServerF1", logHead + "获取数据失败，没有得到返回数据,异常错误");
				setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
			}
			break;
		case 3: 
			var OrderID = OneCmd.C.c;
			var CmdID = OneCmd.C.d;
			doAsyncProcedurce(sandbox, OneCmd, "CacheDo3", {
				token : sandbox.$token,
				dbPool : "",
				ps : publicCmdId,
				cacheId : sandbox.$dynId,
				sqlId : OneCmd.C.c,
				para : $DynFun.getServerPara(sandbox, OneCmd, {})
			}, CmdID);
			break;
		case 4: 
			doServerF1_4(sandbox, OneCmd, RefreshObj, logHead, publicCmdId);
			break;
		case 5: 
			var mTmpContent = OneCmd.C.c;
			if (mTmpContent == undefined) {
				setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
				return;
			}
			var mMainSql = mTmpContent.sqlM;
			var mFlag = mTmpContent.flag;
			var mListSql = mTmpContent.listS;
			var mListArr = mTmpContent.list;
			var mRs = $F.ajaxSync("CacheDo5", {
				token : sandbox.$token,
				dbPool : "",
				ps : publicCmdId,
				cacheId : sandbox.$dynId,
				sqlId : mMainSql,
				para : $DynFun.getServerPara(sandbox, OneCmd, {}),
				fieldList : mListArr,
				fieldSql : mListSql
			}, sandbox.$digest);
			if (mRs) {
				if (mRs.code > -1) {
					var tmpV = mRs.value;
					if (tmpV) {
						setReturnValue(sandbox, OneCmd, tmpV, RefreshObj, logHead);
					} else {
						$PublicFun.err("doServerF1", logHead + "获取数据失败，没有得到返回数据");
						setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
					}
				} else {
					$PublicFun.err("doServerF1", logHead + "获取数据失败，没有得到返回数据:" + mRs.message);
					setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
				}
			} else {
				$PublicFun.err("doServerF1", logHead + "获取数据失败，没有得到返回数据,异常错误");
				setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
			}
			break;
		case 6:
			doServerF1_6(sandbox, OneCmd, RefreshObj, logHead, publicCmdId);
			break;
		case 7:	
			doServerF1_7(sandbox, OneCmd, RefreshObj, logHead, publicCmdId);
			break;
		default:
			$PublicFun.err("doServerF1", "未知类型：" + JSON.stringify(OneCmd));
		}
	},doServerF1_6=function(sandbox, OneCmd, RefreshObj, logHead, publicCmdId){
		var mTmpContent = OneCmd.C.c;
		if (mTmpContent == undefined) {
			$PublicFun.err("doServerF1_6", "配置错误：" + JSON.stringify(OneCmd));
			setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
			return;
		}
		var pubKey = mTmpContent.k;
		if (pubKey== undefined){
			$PublicFun.err("doServerF1_6", "配置错误，无模板Key：" + JSON.stringify(OneCmd));
			setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
			return;
		}
		var mFiltList = mTmpContent.f;
		var dbPool= mTmpContent.d ||'';
		
		mFiltList = $DynFun.replaceCalcContent(sandbox, OneCmd, mFiltList, 0)
		var mRelList=mTmpContent.r; 
		var mParaV={};
		var iCount = mRelList.length;
		for (var i = 0; i < iCount; i++) {
			var mOne = mRelList[i];
			var mOneVar = sandbox.getOneVarStruct(mOne.r.toLowerCase());
			var mValue;
			if (mOneVar == undefined) {
				mValue = "";
			} else {
				mValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
			}
		 	mParaV[mOne.n]=mValue;
		}
		var mRs = $F.ajaxSync("CacheDoPubMDL2", {
			token : sandbox.$token,
			dbPool :dbPool,
			mdlkey:pubKey,
		    page:0,
		    maxRow:0,
		    filter:mFiltList,
		    values:mParaV
		}, sandbox.$digest);
		if (mRs) {
			if (mRs.count > -1) {
				var tmpV = mRs.fields;
				if (tmpV) {
					setReturnValue(sandbox, OneCmd, tmpV, RefreshObj, logHead);
				} else {
					$PublicFun.err("doServerF1", logHead + "获取数据失败，没有得到返回数据");
					setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
				}
			} else {
				$PublicFun.err("doServerF1", logHead + "获取数据失败，没有得到返回数据:" + mRs.message);
				setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
			}
		} else {
			$PublicFun.err("doServerF1", logHead + "获取数据失败，没有得到返回数据,异常错误");
			setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
		}
	},doServerF1_7=function(sandbox, OneCmd, RefreshObj, logHead, publicCmdId){
		var mTmpContent = OneCmd.C.c;
		if (mTmpContent == undefined) {
			$PublicFun.err("doServerF1_7", "配置错误：" + JSON.stringify(OneCmd));
			setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
			return;
		}
		var pubKey = mTmpContent.k;
		if (pubKey== undefined){
			$PublicFun.err("doServerF1_7", "配置错误，无模板Key：" + JSON.stringify(OneCmd));
			setReturnValue(sandbox, OneCmd, [], RefreshObj, logHead);
			return;
		}
		var mFiltList = mTmpContent.f;
		var dbPool= mTmpContent.d ||'';
		
		mFiltList = $DynFun.replaceCalcContent(sandbox, OneCmd, mFiltList, 0)
		var mRelList=mTmpContent.r; 
		var mParaV={};
		var iCount = mRelList.length;
		for (var i = 0; i < iCount; i++) {
			var mOne = mRelList[i];
			var mOneVar = sandbox.getOneVarStruct(mOne.r.toLowerCase());
			var mValue;
			if (mOneVar == undefined) {
				mValue = "";
			} else {
				mValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
			}
		 	mParaV[mOne.n]=mValue;
		}
		var mRs = $F.ajaxSync("CacheDoPubMDL1", {
			token : sandbox.$token,
			dbPool :dbPool,
			mdlkey:pubKey,
		    page:0,
		    maxRow:0,
		    filter:mFiltList,
		    values:mParaV
		}, sandbox.$digest);
		if (mRs) {
			setReturnValue(sandbox, OneCmd, mRs.code, RefreshObj, logHead);
			if (mRs.code < 0) {
				$PublicFun.err("CacheDoPubMDL1", logHead + " Failed:" + mRs.message);
			}
		} else {
			$PublicFun.err("CacheDoPubMDL1", logHead + " Failed Unknow Error");
			setReturnValue(sandbox, OneCmd, -1, RefreshObj, logHead);
		}
	},doServerCmd = function(sandbox, OneCmd, RefreshObj, logHead, publicCmdId) {
		switch (OneCmd.T) {
		case -1:
			doServerF1(sandbox, OneCmd, RefreshObj, logHead, publicCmdId);
			break;
		default:
			$PublicFun.err("doServerCmd", "未知类型：" + JSON.stringify(OneCmd));
		}
	}, doOneOther_98 = function(sandbox, OneCmd, RefreshObj, logHead, publicCmdId) {
		var mTmpStr = OneCmd.C.c;
		var iTmpIndex = mTmpStr.indexOf("|*|");
		if (iTmpIndex < 0) {
			$PublicFun.err("DoOneOther_98", logHead + "执行循环命令集传入参数格式错误，循环条件为空 ，属性为：" + mTmpStr);
			return -1;
		} else {
			var mCommadOrderID = $DynFun.replaceCalcContent(sandbox, OneCmd, mTmpStr.substring(0, iTmpIndex).trim(), 0);
			var mOrderInfo = mTmpStr.substring(iTmpIndex + 3).trim();
			var mCircleValue;
			if (mOrderInfo.substring(0, 1) == "[") {
				mOrderInfo = mOrderInfo.substring(1);
				if (mOrderInfo.substring(mOrderInfo.length - 1) == "]") {
					mOrderInfo = mOrderInfo.substring(0, mOrderInfo.length - 1);
				}
				var mOneVar = sandbox.getOneVarStruct(mOrderInfo.toLowerCase());
				if (mOneVar == undefined) {
					$PublicFun.err("DoOneOther_98", logHead + "执行循环命令集错误，[" + mOrderInfo + "]属性不存在");
					return -1;
				} else {
					if (mOneVar.VT == 4) {
						mCircleValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
					} else {
						$PublicFun.err("DoOneOther_98", logHead + "执行循环命令集错误，循环条件为空 ，属性不为记录集:" + mOrderInfo);
						return -1;
					}
				}
			} else {
				var mRs = $F.ajaxSync("CacheDo2", {
					token : sandbox.$token,
					dbPool : "",
					ps : publicCmdId,
					sqls : [ {
						cacheId : sandbox.$dynId,
						sqlId : mOrderInfo,
						para : $DynFun.getServerPara(sandbox, OneCmd, {})
					} ]
				}, sandbox.$digest);
				if (mRs) {
					if (mRs.code > -1) {
						var tmpV = mRs.value[0];
						if (tmpV) {
							if (tmpV.count > -1) {
								mCircleValue = tmpV.fields;
							} else {
								$PublicFun.err("DoOneOther_98", logHead + "循环SQL执行失败:" + mOrderInfo);
								return -1;
							}
						} else {
							$PublicFun.err("DoOneOther_98", logHead + "循环SQL执行异常:" + mOrderInfo);
							return -1;
						}
					} else {
						$PublicFun.err("DoOneOther_98", logHead + "循环SQL执行失败:" + mOrderInfo);
						return -1;
					}
				} else {
					$PublicFun.err("DoOneOther_98", logHead + "循环SQL执行请求失败:" + mOrderInfo);
					return -1;
				}
			}
			if (mCircleValue instanceof Array) {
				// DoCircleCmdList(cSub(mCircleResult),mCommadOrderID,vCurrentObj);
				return doOneOther_98_1(sandbox, mCircleValue, mCommadOrderID, RefreshObj, logHead);
			} else {
				$PublicFun.err("DoOneOther_98", logHead + "循环SQL执行失败结果为非表格数据:" + mOrderInfo);
				return -1;
			}
		}
	}, 
	
	doOneOther_98_1_1 = function(sandbox, circleCmdId, circleValue, CmdLists, RefreshObj, logHead, p) {
		$PublicFun.logGrp("doOneOther_98_1_1", "  开始循环行数:" + circleValue.length);
		RefreshObj=RefreshObj || {};
		var iCount = circleValue.length;
		sandbox.R["STOPCIRCLE"] = 0;
		for (var i = 0; i < iCount; i++) {
			sandbox.R["CURRENTROW"] = circleValue[i];
			sandbox.$X = 2;
			$PublicFun.log("doOneOther_98_1_1", logHead + "DoCircleCmdList Circle Row :" + i);
			if (p) {
				doOneCmdList(sandbox, "Circel:" + circleCmdId, CmdLists, RefreshObj, circleCmdId,1);
			} else {
				doOneCmdList(sandbox, "Circel:" + circleCmdId, CmdLists, RefreshObj, undefined, 1);// 循环调用命令组
			}
			if (sandbox.R["STOPCIRCLE"] != 0) {
				break;
			}
		}
		sandbox.$X = 0;
		sandbox.$callback(RefreshObj, sandbox.$runtime);
		$PublicFun.log("Callback End", "Circle CmdId:"+circleCmdId);
		$PublicFun.logGrpEnd("doOneOther_98_1_1", "  循环结束 行数:" + circleValue.length);
	}, 
	
	doOneOther_98_1_1_F = function(sandbox, circleCmdId, circleValue, CmdLists, RefreshObj, logHead, p) {
		$PublicFun.logGrp("doOneOther_98_1_1_F", "  开始循环行数:" + circleValue.length);
		var iCount = circleValue.length;
		sandbox.R["STOPCIRCLE"] = 0;
		for (var i = iCount - 1; i >= 0; i--) {
			sandbox.R["CURRENTROW"] = circleValue[i];
			sandbox.$X = 2;
			$PublicFun.log("doOneOther_98_1_1_F", logHead + "DoCircleCmdList Circle Row :" + i);
			if (p) {
				doOneCmdList(sandbox, "Circel:" + circleCmdId, CmdLists, RefreshObj, circleCmdId, 1);// 循环调用命令组
			} else {
				doOneCmdList(sandbox, "Circel:" + circleCmdId, CmdLists, RefreshObj, undefined, 1);// 循环调用命令组
			}

			if (sandbox.R["STOPCIRCLE"] != 0) {
				break;
			}
		}
		sandbox.$X = 0;
		sandbox.$callback(RefreshObj, sandbox.$runtime);
		$PublicFun.log("Callback End", "Circle CmdId:"+circleCmdId);
		$PublicFun.logGrpEnd("doOneOther_98_1_1_F", "  循环结束 行数:" + circleValue.length);
	}, 
	
	doOneOther_98_1 = function(sandbox, circleValue, circleCmdId, RefreshObj, logHead) {
		var mFlag = 0;
		circleCmdId = (circleCmdId + "").trim();
		if (circleCmdId.substring(0, 1).toLowerCase() == "f") {
			mFlag = 1;
			circleCmdId = circleCmdId.substring(1);
		}
		var CmdLists = sandbox.$dynCmds["P" + circleCmdId];
		if (CmdLists) {
			if (mFlag == 0) {
				doOneOther_98_1_1(sandbox, circleCmdId, circleValue, CmdLists, RefreshObj, logHead);
			} else {
				doOneOther_98_1_1_F(sandbox, circleCmdId, circleValue, CmdLists, RefreshObj, logHead);
			}

			return 1;
		} else {
			$PublicFun.log("doOneOther_98_1", logHead + "循环SQL执行命令组不存在:" + circleCmdId);
			return -1;
		}
	},doOneOther_10=function(sandbox, OneCmd, RefreshObj, logHead, publicCmdId){
		//OneCmd.C.k
		//OneCmd.C.t
		//sandbox.$dynId
		//OneCmd.C.c
		$PublicFun.addOneSqlKey(OneCmd.C.k,OneCmd.C.t,sandbox.$dynId,OneCmd.C.c, $DynFun.getServerPara(sandbox, OneCmd, {}));
		$PublicFun.showOneSql();
		setReturnValue(sandbox, OneCmd, 1, RefreshObj, logHead);
	},doOther_88=function(sandbox, OneCmd, RefreshObj, logHead, publicCmdId){//调用服务器命令
		var mCmdObj=OneCmd.C.c;
		if (mCmdObj){
			var cmdKey=mCmdObj.n;
			var mInVar = {};
			var mInStruct = mCmdObj.rel;
			if (mCmdObj.l == 1) { //l==1表示传递本地所有临时变量
				mInVar = $.extend({}, sandbox.$runtime.data.pub, sandbox.$runtime.data.local);
			}
			//然后再看配置了哪些入参，把自己配置的再覆盖上来
			var iCount = mInStruct.length;
			for (var i = 0; i < iCount; i++) {
				mInVar[mInStruct[i].n] = $DynFun.replaceCalcContent(sandbox, OneCmd, mInStruct[i].rv, 0);
			}
			
			var mRs = $F.ajaxSync("SeverCmdRunIn", {
				token : sandbox.$token,
				cmdKey : cmdKey,
				para : mInVar
			}, sandbox.$digest);
			$PublicFun.log("doOneOther_88", logHead + " Return:" + JSON.stringify(mRs));
			if (mRs) {
				if (mRs.code > -1) {
					setReturnValue(sandbox, OneCmd,JSON.parse(mRs.value), RefreshObj, logHead);
				} else {
					setReturnValue(sandbox, OneCmd, [-1, mRs.message], RefreshObj, logHead);
				}
			} else {
				setReturnValue(sandbox, OneCmd, [-1, "未得到返回值"], RefreshObj, logHead);
			}
		} else {
			setReturnValue(sandbox, OneCmd, [-1, "未得到调用结构"], RefreshObj, logHead);
		}
	},
	doOneOther = function(sandbox, OneCmd, RefreshObj, logHead, publicCmdId) {
		switch (OneCmd.T) {
		case 10:
			doOneOther_10(sandbox, OneCmd, RefreshObj, logHead, publicCmdId);
			break;
		case 99:
			var mTmpOrder = $DynFun.replaceCalcContent(sandbox, OneCmd, OneCmd.C.c, 0);
			if (sandbox.$dynCmds["P" + mTmpOrder]) {
				doOneCmdList(sandbox, "P" + mTmpOrder, sandbox.$dynCmds["P" + mTmpOrder]);
				setReturnValue(sandbox, OneCmd, 1, RefreshObj, logHead);
			} else {
				setReturnValue(sandbox, OneCmd, -1, RefreshObj, logHead);
			}
			break;
		case 88:
			doOther_88(sandbox, OneCmd, RefreshObj, logHead, publicCmdId);
			break;
		case 89:
			var mTmpOrder = $DynFun.replaceCalcContent(sandbox, OneCmd, OneCmd.C.c, 0);
			var CmdList = $D.getPCmd(sandbox.$runtime, mTmpOrder);
			if (CmdList) {
				doOneCmdList(sandbox, "G" + mTmpOrder, CmdList, undefined, mTmpOrder);
				setReturnValue(sandbox, OneCmd, 1, RefreshObj, logHead);
			} else {
				setReturnValue(sandbox, OneCmd, -1, RefreshObj, logHead);
			}
			break;
		case 98:
			setReturnValue(sandbox, OneCmd, doOneOther_98(sandbox, OneCmd, RefreshObj, logHead, publicCmdId), RefreshObj, logHead);
			break;
		case 90:
			doOther_90(sandbox, OneCmd, RefreshObj, logHead, publicCmdId);
			break;
		case 91:
			doOther_91(sandbox, OneCmd, RefreshObj, logHead, publicCmdId);
			break;
		case 95:
			doOther_95(sandbox, OneCmd, RefreshObj, logHead);
			break;
		case 93:
			doOther_93(sandbox, OneCmd, RefreshObj, logHead);
			break;
		case 92:
			doOther_92(sandbox, OneCmd, RefreshObj, logHead);
			break;
		default:
		}
	}, 
	
	doOther_95=function(sandbox, OneCmd, RefreshObj, logHead){
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, OneCmd, OneCmd.C.c, 0);
		var mArray = $PublicFun.stringToArray(mTmpContent,"|****|");
		if (mArray.length!=9){
			$PublicFun.log("doOther_95", logHead + "报表参数错误:"+mTmpStr);
			setReturnValue(sandbox, OneCmd, -1, RefreshObj, logHead);
			return ;
		}
		var mRptID = mArray[0], mPara=mArray[8], mResultP=[]
		var mParas = $PublicFun.stringToArray(mPara,"|#***#|"); 
	    var iCount= mParas.length;
		for (var i = 0; i < iCount; i++) {
			var mOneP = $PublicFun.stringToArray(mParas[i],"|#*|*#|");
			$PublicFun.log("doOther_95", logHead + " 参数 :"+"["+i+"]"+mParas[i]+" Length:"+mOneP.length);
			if (mOneP.length==4){
				var mShow;
				if ( mOneP[3].trim()==""){
					mShow= mOneP[2];
				}else{
					mShow= mOneP[3];
				}
				mResultP.push({
					id :  mOneP[0].toLowerCase(),
					desc : mShow,
					value : mOneP[2]
				});
				
			}			
		}
		$PublicFun.log("doOther_95", 'Run ReportID:'+mRptID+" Para:"+JSON.stringify(mResultP));
		sandbox.runReport(mRptID, mResultP); 
		setReturnValue(sandbox, OneCmd, 1, RefreshObj, logHead);
	},doOther_93 = function(sandbox, OneCmd, RefreshObj, logHead) {
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, OneCmd, OneCmd.C.c, 0);
		mTmpContent = doOther_92_1(sandbox, mTmpContent);
		mTmpContent = doOther_92_2(sandbox, mTmpContent);
		mTmpContent = doOther_92_3(sandbox, mTmpContent);
		mTmpContent = sandbox.evalValue(mTmpContent);
		setReturnValue(sandbox, OneCmd, mTmpContent, RefreshObj, logHead);
	}, doOther_92_3_1 = function(sandbox, nextContent, oneVar) {
		var grid = $DynFun.getSystemValue(sandbox, oneVar.pM, oneVar.pS, oneVar.VT);
		if (grid instanceof Array) {
			var iB = nextContent.indexOf("||");
			var mTmpArr = [];
			// push()
			while (iB > -1) {
				var mTmpValue = nextContent.substring(0, iB).trim();
				if (isNaN(mTmpValue)) {
					mTmpArr.push($PublicFun.stringToInt(mTmpValue) - 1);
				} else {
					mTmpArr.push($PublicFun.stringToInt(mTmpValue) - 1);
				}
				nextContent = nextContent.substring(iB + 2);
				iB = nextContent.indexOf("||");
			}
			if (nextContent.trim()) {
				mTmpArr.push(nextContent);
			}
			var mReturnStr = "";
			var iCount = grid.length, jCount = mTmpArr.length;
			for (var i = 0; i < iCount; i++) {
				var mTmpOneA = grid[i];
				for (var j = 0; j < jCount; j++) {
					if (isNaN(mTmpArr[j])) {
						mReturnStr += mTmpArr[j];
					} else {
						if (mTmpArr[j] > jCount) {
						} else {
							mReturnStr += mTmpOneA[mTmpArr[j]];
						}
					}
				}
			}
			return mReturnStr;
		} else {
			return "";
		}
	}, doOther_92_3 = function(sandbox, content) {
		var iB = content.indexOf("{");
		while (iB >= 0) {
			var iE = content.indexOf("}", iB);
			if (iE > iB) {
				var mProName = content.substring(iB + 1, iE);
				var iB1 = mProName.indexOf("||");
				if (iB1 > 0) {
					var mNameGrid = mProName.substring(0, iB1);
					var mOneVar = sandbox.getOneVarStruct(mNameGrid.toLowerCase());
					if (mOneVar) {
						if (mOneVar.VT == 4) {
							var mTmpStr = doOther_92_3_1(sandbox, mProName.substring(iB1 + 2), mOneVar);
							content = content.substring(0, iB) + mTmpStr + content.substring(iE + 1);
							iE = iB + mTmpStr.length;
						} else {
							$PublicFun.err("cOneDataRoot.DoReplaceGrid", "字符串替换：" + mProName + " 非表格变量");
						}
					} else {
						$PublicFun.err("cOneDataRoot.DoReplaceGrid", "字符串替换：" + mProName + "  表格变量不存在");
					}
				}
				iB = content.indexOf("{", iE);
			} else {
				break;
			}
		}
		return content;
	}, doOther_92_2 = function(sandbox, content) {
		var iB = content.indexOf("[");
		// var iE:int,mTmp:OneProperty,mProName:String,mAllRel:Dictionary=new Dictionary();
		while (iB >= 0) {
			var iE = content.indexOf("]", iB);
			if (iE > iB) {
				var mProName = content.substring(iB + 1, iE);
				var mOneVar = sandbox.getOneVarStruct(mProName.toLowerCase());
				if (mOneVar) {
					var mTmpValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
					content = content.substring(0, iB) + mTmpValue + content.substring(iE + 1);
				}
				iB = content.indexOf("[", iB + 1);
			} else {
				break;
			}
		}
		return content;
	}, doOther_92_1 = function(sandbox, content) {
		var iB1 = content.toUpperCase().indexOf("%B%");
		if (iB1 < 0) {
			return content;
		}
		var iE1 = content.toUpperCase().indexOf("%E%");
		if (iE1 < 0) {
			return content;
		}
		while (iB1 > -1 && iE1 > -1) {
			var iB = content.toUpperCase().indexOf("*{", iB1);
			if (iB > iB1 && iB < iE1) {
				var iE = content.toUpperCase().indexOf("}*", iB + 1);
				if (iE > -1) {
					var mProName = content.substring(iB + 2, iE);
					var mOneVar = sandbox.getOneVarStruct(mProName.toLowerCase());
					if (mOneVar) {
						var mTmpValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
						if (mTmpValue == "") {
							content = content.substring(0, iB1) + content.substring(iE1 + 3);
						} else if ((mOneVar.VT == 1 || mOneVar.VT == 5) && $PublicFun.stringToInt(mTmpValue) == 0) {
							content = content.substring(0, iB1) + content.substring(iE1 + 3);
						} else {
							content = content.substring(0, iB) + mTmpValue + content.substring(iE + 2);
						}
					} else {
						iB1++;
					}
				} else {
					iB1++;
				}
			} else {
				iB1++;
			}
			iB1 = content.toUpperCase().indexOf("%B%", iB1);
			if (iB1 < 0) {
				iE1 = -1;
			} else {
				iE1 = content.toUpperCase().indexOf("%E%");// MyFunction.IndexOfIngoreCase(vReplaceStr,"%E%",iB1);
			}
		}
		return content.replace2("%B%", "").replace2("%E%", "");
	}, doOther_92 = function(sandbox, OneCmd, RefreshObj, logHead) {
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, OneCmd, OneCmd.C.c, 0);
		mTmpContent = doOther_92_1(sandbox, mTmpContent);
		mTmpContent = doOther_92_2(sandbox, mTmpContent);
		mTmpContent = doOther_92_3(sandbox, mTmpContent);
		setReturnValue(sandbox, OneCmd, mTmpContent, RefreshObj, logHead);
	},
	// doOther_96=function(sandbox,OneCmd,RefreshObj,logHead){
	// if ($PublicFun.TimeCacheKey){
	// var runKey= OneCmd.C.c;
	// runKey=replaceCalcContent(sandbox,OneCmd, runKey,0);
	// if (runKey==undefined){runKey="main";}
	// if (runKey==""){runKey="main";}
	// var runKey=runKey.trim().toLowerCase();
	// if ($PublicFun.TimeCacheKey[runKey]!=''){
	// $PublicFun.TimeCacheKey[runKey]=undefined;
	// setReturnValue(sandbox, OneCmd,1, RefreshObj, logHead);
	// }else{
	// setReturnValue(sandbox, OneCmd,0, RefreshObj, logHead);
	// }
	// }else{
	// setReturnValue(sandbox, OneCmd,0, RefreshObj, logHead);
	// }
	// },

	doOther_91 = function(sandbox, OneCmd, RefreshObj, logHead, publicCmdId) {
		var content = OneCmd.C.c;
		var cmdId = OneCmd.C.d;
		// var mIndex=mTmp.indexOf("|*|"),cmdId,content;
		// if (mIndex>-1){
		// cmdId=mTmp.substring(0,mIndex);
		// content=mTmp.substring(mIndex+3);
		// }else{
		// cmdId="";content=mTmp;
		// }
		doAsyncExec(sandbox, OneCmd, "CacheDo1", {
			token : sandbox.$token,
			dbPool : "",
			ps : publicCmdId,
			sqls : [ {
				cacheId : sandbox.$dynId,
				sqlId : content,
				para : $DynFun.getServerPara(sandbox, OneCmd, {},OneCmd.C.k)
			} ]
		}, cmdId, logHead);
	}, doOther_90 = function(sandbox, OneCmd, RefreshObj, logHead, publicCmdId) {
		// var mTmp=OneCmd.C.c;
		var content = OneCmd.C.c;
		var cmdId = OneCmd.C.d;

		// var mIndex=mTmp.indexOf("|*|"),cmdId,content;
		// if (mIndex>-1){
		// cmdId=mTmp.substring(0,mIndex);
		// content=mTmp.substring(mIndex+3);
		// }else{
		// cmdId="";content=mTmp;
		// }
		doAsyncSelect(sandbox, OneCmd, "CacheDo2", {
			token : sandbox.$token,
			dbPool : "",
			ps : publicCmdId,
			sqls : [ {
				cacheId : sandbox.$dynId,
				sqlId : content,
				para : $DynFun.getServerPara(sandbox, OneCmd, {},OneCmd.C.k)
			} ]
		}, cmdId, logHead);
	}, doType8_Prepare = function(String) {
		try {
			var i1 = String.indexOf("|*|");
			var i2 = String.indexOf("|*|", i1 + 1);
			if (i1 > -1) {
				if (i2 > -1) {
					var mSource1 = String.substring(0, i1);
					var mfrom = String.substring(i1 + 3, i2);
					var mto = String.substring(i2 + 3);
					return $DynFun.replaceStr(mSource1, mfrom, mto, 0);
				} else {
					return $DynFun.replaceStr(String, "'", "''", 0);
				}
			} else {
				return $DynFun.replaceStr(String, "'", "''", 0);
			}
		} catch (e) {
			$PublicFun.err("Prepare", "Replace String Failed", e);
			return String;
		}

	}, doType8_GetID = function(sandbox, inStr) {
		var mArray = inStr.split(",");
		if (mArray.length < 0) {
			$PublicFun.err("GETID", "GetID", "GET ID Failed 参数传入错误：" + inStr);
			return "";
		}
		if (mArray[0] == "" || mArray[0] == "0") {
			if (mArray.length > 7) {
				var mTmpIDInfo = $F.ajaxSync(mArray[7] + "/JSGenerateServlet2", {
					token : sandbox.$token,
					dbPool : '',
					name : 'System.GetID',
					P1 : mArray[1],
					P2 : mArray[2],
					P3 : mArray[3],
					P4 : mArray[4],
					P5 : mArray[5],
					P6 : mArray[6]
				}, sandbox.$digest);
				if (mTmpIDInfo == undefined) {
					return "";
				}
				if (mTmpIDInfo.code == 1) {
					return mTmpIDInfo.value;
				} else {
					return "";
				}
			} else {
				var mTmpIDInfo = $F.ajaxSync("JSGenerateServlet2", {
					token : sandbox.$token,
					dbPool : '',
					name : 'System.GetID',
					P1 : mArray[1],
					P2 : mArray[2],
					P3 : mArray[3],
					P4 : mArray[4],
					P5 : mArray[5],
					P6 : mArray[6]
				}, sandbox.$digest);// : function(method, data)
				if (mTmpIDInfo == undefined) {
					return "";
				}
				if (mTmpIDInfo.code == 1) {
					return mTmpIDInfo.value;
				} else {
					return "";
				}
			}
		} else {
			return mArray[0];
		}

	}, 
	
	doType8 = function(sandbox, oneCmd, RefreshObj, logHead) {
		var content = oneCmd.C;
		var mTmpContent = $DynFun.replaceCalcContent(sandbox, oneCmd, content.c || "", 0);// = this.replaceVarValue(mTmpOne.RelList,mTmpOne.Filter,1);
		// console.log(mTmpContent);
		switch (content.t) {
		case 0: // 普通公式
			return setReturnValue(sandbox, oneCmd, sandbox.evalValue(mTmpContent.replace(/\beval\((.*)\)/gi, '$1')), RefreshObj, logHead);
		case 1:// merge String
			return setReturnValue(sandbox, oneCmd, mTmpContent, RefreshObj, logHead);
		case 2:// PREPARE
			return setReturnValue(sandbox, oneCmd, doType8_Prepare(mTmpContent), RefreshObj, logHead);
		case 3:// msgbox
			$F.alert(mTmpContent);
			return 1;
		case 4:// msgbox flex
			$F.info(mTmpContent);
			return 1;
		case 5:// msgbox question
			$F.alert("此方法已经不支持");
			var mResult = confirm(mTmpContent);
			if (mResult) {
				return setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
			} else {
				return setReturnValue(sandbox, oneCmd, 0, RefreshObj, logHead);
			}

		case 6:// getid
			return setReturnValue(sandbox, oneCmd, doType8_GetID(sandbox, mTmpContent), RefreshObj, logHead);
		case 7:// GLOBALVALUEGET
			return setReturnValue(sandbox, oneCmd, $DynFun.getPublicValue(mTmpContent), RefreshObj, logHead);
		case 8:// GLOBALVALUESET
			var iIndex = mTmpContent.indexOf(",");
			if (iIndex > -1) {
				$DynFun.setPublicVar(mTmpContent.substring(0, iIndex), mTmpContent.substring(iIndex + 1));
				return 1;
			} else {
				return 0;
			}
		case 9:// SendWO
			return setReturnValue(sandbox, oneCmd, doType8_9(sandbox, mTmpContent, logHead), RefreshObj, logHead);
		case 10: // sendDyn
			return setReturnValue(sandbox, oneCmd, doType8_10(sandbox, mTmpContent, logHead), RefreshObj, logHead);
		case 11: // //批量设置
			doType8_BatchSet(sandbox, oneCmd, mTmpContent, RefreshObj, logHead);
			break;
		case 12:
			sandbox.refresh();
			return 1;
		default:
		}
		return 1;
	}, 
	
	doType8_9 = function(sandbox, contentStr, logHead) {
		var mArr = $PublicFun.stringToArray(contentStr, ",");
		if (mArr.length < 4) {
			$PublicFun.err("doType8_9", logHead + " 参数错误 :" + contentStr);
			return -1;
		}
		var oId = (mArr[0] || "").trim();
		var oTId = (mArr[1] || "").trim();
		var addinId = (mArr[2] || "").trim();
		var msubStepId;
		if (mArr.length == 6) {
			msubStepId = (mArr[5] || "").trim();
		} else {
			msubStepId = "";
		}
		var mTabName;
		if (mArr.length > 4) {
			mTabName = (mArr[4] || "").trim();
			if (mTabName == "") {
				mTabName = "工单";
			}
		} else {
			mTabName = "工单 ";
		}
		try {
			sandbox.$instance.project.events.notify($CONST.EVENT.OPEN_WO, {
				addinId : addinId,
				tabName : mTabName,
				oId : oId,
				otId : oTId,
				subId : msubStepId
			});
			return 1;
		} catch (e) {
			$PublicFun.err("doType8_9", logHead + "异常错误", e);
			return -1;
		}
	}, doType8_10 = function(sandbox, contentStr, logHead) {
		var mArr = $PublicFun.stringToArray(contentStr, ",");
		if (mArr.length < 4) {
			$PublicFun.err("doType8_10", logHead + " 参数错误 :" + contentStr);
			return -1;
		}
		var oId = (mArr[0] || "").trim();
		var oTId = (mArr[1] || "").trim();
		var addinId = (mArr[2] || "").trim();
		var mTabName;
		if (mArr.length > 4) {
			mTabName = (mArr[4] || "").trim();
			if (mTabName == "") {
				mTabName = "页面";
			}
		} else {
			mTabName = "页面 ";
		}
		try {
			sandbox.$instance.project.events.notify($CONST.EVENT.OPEN_OBJ, {
				addinId : addinId,
				tabName : mTabName,
				oId : oId,
				otId : oTId
			});
			// sandbox.$instance.project.openAddinDynById(addinId,mTabName, oId,oTId);
			return 1;
		} catch (e) {
			$PublicFun.err("doType8_10", logHead + " 异常错误:", e);
			return -1;
		}
	}, doType8_BatchSet_2 = function(sandbox, t, name, value, RefreshObj) {
		try {
			t = $PublicFun.stringToInt(t);
			switch (t) {
			case 1: // 局部变量
				$DynFun.setLocateVar(sandbox, name, value);
				break;
			case 2: // 属性
				var mTmpOne = sandbox.getOneVarStruct(name.toLowerCase());
				if (mTmpOne) {
					RefreshObj[name.toLowerCase()] = $DynFun.refreshObjNew($DynFun.setSystemVar(sandbox, mTmpOne, value));
				} else {
					$PublicFun.log("doType8_BatchSet_2", "未找到对应属性名：" + name + " Value:" + value);
				}
				break;
			case 3: // 全局变量
				$DynFun.setPublicVar(name, value);
				break;
			default:
				$PublicFun.err("doType8_BatchSet_2", "未知类型 name：" + name + " Value:" + value);
			}
		} catch (e) {
			$PublicFun.err("doType8_BatchSet_2", "异常错误 Name：" + name + " Value:" + value + " Type:" + t, e);
		}
	}, doType8_BatchSet_1 = function(sandbox, Express, RefreshObj) {
		// log("Test",Express);
		var Ret = $PublicFun.stringSplitOne(Express, "|&|");
		var mTmp1, mTmp2, mTmp3, mTmp4;
		if (Ret.F > 0) {
			mTmp1 = Ret.V.trim();
		} else {
			$PublicFun.err("doType8_BatchSet_1", " 格式错误：" + Express);
			return -1;
		}
		Ret = $PublicFun.stringSplitOne(Ret.N, "|&|");
		if (Ret.F > 0) {
			mTmp2 = Ret.V.trim();
		} else {
			$PublicFun.err("doType8_BatchSet_1", " 格式错误：" + Express);
			return -1;
		}
		Ret = $PublicFun.stringSplitOne(Ret.N, "|&|");
		if (Ret.F > 0) {
			mTmp3 = Ret.V.trim();
			mTmp4 = Ret.N.trim();
		} else {
			$PublicFun.log("doType8_BatchSet_1", " 格式错误：" + Express);
			return -1;
		}
		mTmp1 = $PublicFun.stringToInt(mTmp1);
		// console.log("1:"+mTmp1+" 2:"+mTmp2+" 3:"+mTmp3+" 4:"+mTmp4);
		switch (mTmp1) {
		case 1:// 全局变量
			// console.log("1:"+mTmp1+" 2:"+mTmp2+" 3:"+mTmp3+" 4:"+mTmp4);
			doType8_BatchSet_2(sandbox, mTmp3, mTmp4, $DynFun.getSystemStatic(sandbox, mTmp2), RefreshObj);
			break;
		case 2:// 局部变量
			doType8_BatchSet_2(sandbox, mTmp3, mTmp4, $DynFun.getLocateValue(sandbox, mTmp2), RefreshObj);
			break;
		case 3:// 属性
			var mOneVar = sandbox.getOneVarStruct(mTmp2.toLowerCase());
			var mValue;
			if (mOneVar == undefined) {
				mValue = "";
			} else {
				mValue = $DynFun.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
			}
			// console.log("Name:"+mTmp2+" value:"+mValue);
			doType8_BatchSet_2(sandbox, mTmp3, mTmp4, mValue, RefreshObj);
			break;
		case 4:// 自定义全局
			doType8_BatchSet_2(sandbox, mTmp3, mTmp4, $DynFun.getPublicValue(mTmp2), RefreshObj);
			break;
		case 5:// 常量
			doType8_BatchSet_2(sandbox, mTmp3, mTmp4, mTmp2, RefreshObj);
			break;
		default:
			$PublicFun.err("doType8_BatchSet_1", "未知的类型：" + Express);
		}
	}, doType8_BatchSet = function(sandbox, oneCmd, Express, RefreshObj, logHead) {
		var Ret = $PublicFun.stringSplitOne(Express, "|*|");
		while (Ret.F > 0) {
			if (Ret.V.trim()) {
				doType8_BatchSet_1(sandbox, Ret.V.trim(), RefreshObj);
			}
			Ret = $PublicFun.stringSplitOne(Ret.N, "|*|");
		}
		if (Ret.N.trim()) {
			doType8_BatchSet_1(sandbox, Ret.N.trim(), RefreshObj);
		}
		setReturnValue(sandbox, oneCmd, 1, RefreshObj, logHead);
	}, doAsyncExec = function(sandbox, OneCmd, method, postData, cmdId, logHead) {
		$F.ajaxAsync(method, postData, function(data) {
			if (sandbox.$dynCmds["P" + cmdId]) {
				var ReObj = {};
				if (data) {
					setReturnValue(sandbox, OneCmd, data.code, ReObj, logHead);
					doOneCmdList(sandbox, "AsyncExec-P" + cmdId, sandbox.$dynCmds["P" + cmdId], ReObj);
				} else {
					setReturnValue(runtime, OneCmd, -1, ReObj, logHead);
					doOneCmdList(sandbox, "AsyncExec-P" + cmdId, sandbox.$dynCmds["P" + cmdId], ReObj);
				}
			} else {
				$PublicFun.err("doAsyncExecSql", "Async result No Cmd List Method:" + method + " callback CMDID:" + cmdId + " postData:" + JSON.stringify(postData));
				var mRefresh = {}
				if (data) {
					setReturnValue(sandbox, OneCmd, data.code, mRefresh, logHead);
				} else {
					setReturnValue(sandbox, OneCmd, -1, mRefresh, logHead);
				}
				if (sandbox.$callback != undefined) {
					sandbox.$callback(mRefresh, sandbox.$runtime);
				}
				$PublicFun.log("Callback Procedure End", logHead);
			}
		}, sandbox.$project.digest);
	}, doAsyncSelect = function(sandbox, OneCmd, method, postData, cmdId, logHead) {
		$F.ajaxAsync(method, postData, function(data) {
			var ReObj = {};
			if (sandbox.$dynCmds["P" + cmdId]) {
				if (data) {
					if (data.code > -1) {
						var Rs = data.value[0];
						if (Rs) {
							if (Rs.count > -1) {
								setReturnValue(sandbox, OneCmd, Rs.fields, ReObj, logHead);
								doOneCmdList(sandbox, "AsyncSelect-P" + cmdId, sandbox.$dynCmds["P" + cmdId], ReObj);
							} else {
								$PublicFun.err("doAsyncSelect", logHead + "获取数据失败，没有得到返回数据,count<0");
								setReturnValue(sandbox, OneCmd, [], ReObj, logHead);
								doOneCmdList(sandbox, "AsyncSelect-P" + cmdId, sandbox.$dynCmds["P" + cmdId], ReObj);
							}
						} else {
							$PublicFun.err("doAsyncSelect", logHead + "获取数据失败，没有得到返回数据,异常错误");
							setReturnValue(sandbox, OneCmd, [], ReObj, logHead);
							doOneCmdList(sandbox, "AsyncSelect-P" + cmdId, sandbox.$dynCmds["P" + cmdId], ReObj);
						}
					} else {
						$PublicFun.err("doAsyncSelect", logHead + "获取数据失败，没有得到返回数据:" + data.message);
						setReturnValue(sandbox, OneCmd, [], ReObj, logHead);
						doOneCmdList(sandbox, "AsyncSelect-P" + cmdId, sandbox.$dynCmds["P" + cmdId], ReObj);
					}
				} else {
					$PublicFun.err("doAsyncSelect", logHead + "获取数据失败，没有得到返回数据,异常错误");
					setReturnValue(sandbox, OneCmd, [], ReObj, logHead);
					doOneCmdList(sandbox, "AsyncSelect-P" + cmdId, sandbox.$dynCmds["P" + cmdId], ReObj);
				}
			} else {
				$PublicFun.log("doAsyncSelectSql", "Async result No Cmd List Method:" + method + " cmdID:" + cmdId + "  postData:" + JSON.stringify(postData));
				if (data) {
					if (data.code > -1) {
						var Rs = data.value[0];
						if (Rs) {
							if (Rs.count > -1) {
								setReturnValue(sandbox, OneCmd, Rs.fields, ReObj, logHead);
							} else {
								$PublicFun.err("doAsyncSelect", logHead + "获取数据失败，没有得到返回数据,count<0");
								setReturnValue(sandbox, OneCmd, [], ReObj, logHead);
							}
						} else {
							$PublicFun.err("doAsyncSelect", logHead + "获取数据失败，没有得到返回数据,异常错误");
							setReturnValue(sandbox, OneCmd, [], ReObj, logHead);
						}
					} else {
						$PublicFun.err("doAsyncSelect", logHead + "获取数据失败，没有得到返回数据:" + data.message);
						setReturnValue(sandbox, OneCmd, [], ReObj, logHead);
					}
				} else {
					$PublicFun.err("doAsyncSelect", logHead + "获取数据失败，没有得到返回数据,异常错误");
					setReturnValue(sandbox, OneCmd, [], ReObj, logHead);
				}
				if (sandbox.$callback != undefined) {
					sandbox.$callback(ReObj, sandbox.$runtime);
				}
				$PublicFun.log("Callback Procedure End", logHead);
			}
		}, sandbox.$project.digest);
	}, doAsyncProcedurce = function(sandbox, OneCmd, method, postData, cmdId, logHead) {
		$F.ajaxAsync(method, postData, function(data) {
			if (sandbox.$dynCmds["P" + cmdId.trim()]) {
				if (data) {
					sandbox.R["RESULTSUCC"] = data.code; // valueListObj
					if (data.code > -1) {
						sandbox.R["RESULTARRAY"] = data.value;
					} else {
						sandbox.R["RESULTDESC"] = data.message;
					}
				} else {
					sandbox.R["RESULTSUCC"] = -2
					sandbox.R["RESULTDESC"] = "异常错误";
				}
				var ReObj = {};
				setReturnValue(sandbox, OneCmd, sandbox.R["RESULTSUCC"], ReObj, logHead);
				doOneCmdList(sandbox, "Async-P" + OneCmd.C.c, sandbox.$dynCmds["P" + cmdId.trim()], ReObj);
			} else {
				$PublicFun.log("doAsyncMethod", "Async result No Cmd List Method:" + method + " postData:" + JSON.stringify(postData));
				var mRefresh = {}
				if (data) {
					setReturnValue(sandbox, OneCmd, data.code, mRefresh, logHead);
				} else {
					setReturnValue(sandbox, OneCmd, -2, mRefresh, logHead);
				}
				if (sandbox.$callback != undefined) {
					sandbox.$callback(mRefresh, sandbox.$runtime);
				}
				$PublicFun.log("Callback Procedure End", logHead);
			}
		}, sandbox.$project.digest);
	};

	var E_Calc = function(instance, callback) {
		this.callback = callback;
		this.instance = instance;
		if (! this.instance.$JETC)
			this.instance.$JETC = {};
		return this;
	};

	E_Calc.prototype = {
		doCmdList : function(CmdId, CmdList, id, impVar, runtime) {
			if (! CmdList || CmdList.length == 0)
				return;
			
			var sandbox = new SandBox(this, 0, impVar, runtime);
			try {
				if (id) {
					var inObj = {
						"#" : id
					};
					doOneCmdList(sandbox, CmdId, CmdList, inObj);
				} else {
					doOneCmdList(sandbox, CmdId, CmdList);
				}
			} catch (e) {
				$F.err('Cmd - doCmdList', e)
			}
			//return sandbox.R;
		},

		doEval : function(express, impVar, runtime) { // 只在流程判断时用到，组件无流程，所以组件对应的信息直接默认了
			var sandbox = new SandBox(this, 0, impVar, runtime);
			express = $DynFun.replacePropertyVarName(sandbox, express);
			// console.log(express);
			// return sandbox.evalValue(express);
			return sandbox.evalValue(express);
		},
		
		getMDLPara : function(mdlId, runtime) {
			var sandbox = new SandBox(this, 0, {}, runtime);
			//return getMDLServerPara(sandbox, mdlId);
			return getMDLServerPara(sandbox, mdlId);
		}
	};

	window.E_Calc = E_Calc;
	
	var SandBox = function(core, circle, impvar, runtime) {
		if (!impvar)
			impvar = {};
		impvar.RUNTIME = runtime;

		this.R = $.extend(impvar, runtime.data.pub, runtime.data.local);
		this.$E = {}; // 用于保护框架
		this.$D = {}; // 用于保护框架
		this.$M = {}; // 用于保护框架
		this.$P = {}; // 用于保护框架
		this.$Z = {}; // 用于保护动态页面全局
		this.$C = {}; // 用于CIT对象的保护
		this.$X = circle; // 循环状态位
		this.$pubVar = runtime.props.pub; // 公共变量定义
		this.$pubData = runtime.data.pub; // 公共变量数据
		this.$locVar = runtime.props.local; // 私有变量定义
		this.$locData = runtime.data.local; // 私有变量数据
		//this.$dynId = (runtime.struct.dynFlag ? runtime.struct.id : runtime.struct.GroupId);
		this.$dynId = runtime.struct.id; // 动态页面主结构ID
		this.$dynCmds = runtime.struct.CmdList; // 动态页面命令集合
		this.$struct = runtime.struct;
		this.$runtime = runtime; // 当前运行环境
		this.$callback = core.callback; // 回调方法
		this.$instance = core.instance; // 当前实例
		this.$project = core.instance.project;	// 当前项目
		this.$token = core.instance.project.token; // 当前用户凭据
		this.$digest = core.instance.project.digest;
		this.$softphone = window.$E.softphone;			// 软电话
		
		this.Event = new $PublicFun.$LIB.EVENT(this);
		this.Roll = new $PublicFun.$LIB.ROLL(this);
		this.Grid = new $PublicFun.$LIB.GRID(this);
		this.Security = new $PublicFun.$LIB.SECURITY(this);
		this.Property = new $PublicFun.$LIB.PROPERTY(this);
		this.Codetable = new $PublicFun.$LIB.CODETABLE(this);
		this.Perz = new $PublicFun.$LIB.PERZ(this);
		this.Step = new $PublicFun.$LIB.STEP(this);
		this.Utils = new $PublicFun.$LIB.UTILS(this);
		this.SMS = new $PublicFun.$LIB.SMS(this); 
		this.Bound = new $PublicFun.$LIB.BOUND(this);
		this.Merge = new $PublicFun.$MERGE(this);
		this.Pinyin = new $PublicFun.$LIB.PINYIN(this);
		
		if ($PublicFun.$ADVLIB){
			this.Jedis = new $PublicFun.$ADVLIB.JEDIS(this);
			this.File = new $PublicFun.$ADVLIB.FILE(this);
			this.Commons = new $PublicFun.$ADVLIB.COMMONS(this);
			this.WO3 = new $PublicFun.$ADVLIB.WO3(this);
			this.Shorten = new $PublicFun.$ADVLIB.SHORTEN(this);
			this.Searcher = new $PublicFun.$ADVLIB.SEARCHER(this);
			this.Perfers = new $PublicFun.$ADVLIB.PERFERS(this);
		}

		
		this.Callback = {
			sandbox: this,
			register : function(name, callback) {
				var sandbox = this.sandbox;
				if ($.isFunction(callback))
					sandbox.setInstanceItem('_callback_' + name, callback);
				else {
					if (! callback)
						return $F.err('Callback - register', '回调命令未定义');
					sandbox.setInstanceItem('_callback_' + name, function(v){
						sandbox.$instance.doCmd('P' + callback, {
							RESULT : v
						}, sandbox.$runtime)
					});
				}
			},
			
			fire : function(name, ev) {
				var callback = this.sandbox.getInstanceItem('_callback_' + name);
				if (callback == undefined)
					$F.err('Callback - fire', '未注册的回调函数: ' + name);
				else {
					if ($.isFunction(callback))
						callback(ev);
					else
						$F.err('Callback - fire', '无效的回调函数', callback)
				}
			}
		}
	};

	SandBox.prototype = {
		evalValue : function(express) {
			try {
				return eval('with(this) {\n' + express + '\n}');
			} catch (e) {
				if (e instanceof StopException) {
//					if (e.message)
//						$F.log('Sandbox - evalValue', 'Stop reason: ' + e.message);
					return 'STOP-RUN-NEXT-COMMAND';
				} else {
					$F.err('SandBox - eval', '[Source] ' + express, e);
					console.error(e);
				}
			}
		},
		showsubsql: function(sqlkey){
			$PublicFun.showOneSql(sqlkey);
			return 1;
		},
		clearsubsql:function(sqlkey,sqlIndex){
			//var iResult= $PublicFun.clearOneSqlKey(sqlkey,sqlIndex);
			//$PublicFun.log("clearsubsql", "清除所有SQL片段, Key:"+ sqlkey+ ", index:"+sqlIndex+", Result:"+iResult);
			//return iResult;
			return $PublicFun.clearOneSqlKey(sqlkey,sqlIndex);
		},
		clearcache : function() {
			this.$instance.$cacheOneDyn = {};
			return 1;
		},
		clearonecache : function(key) {
			if (this.$instance.$cacheOneDyn[key.trim().toLowerCase()]) {
				this.$instance.$cacheOneDyn[key.trim().toLowerCase()] = "";
			}
			return 1;
		},
		addcache : function(key, data) {
			if (! this.$instance.$cacheOneDyn) 
				this.$instance.$cacheOneDyn = {};
			this.$instance.$cacheOneDyn[key.trim().toLowerCase()] = data;
		},
		getcache : function(key) {
			if (this.$instance.$cacheOneDyn) {
				if (this.$instance.$cacheOneDyn[key.trim().toLowerCase()]) {
					return this.$instance.$cacheOneDyn[key.trim().toLowerCase()];
				} else {
					$PublicFun.log("getCache", "key不存在" + key);
					return "";
				}
			} else {
				$PublicFun.log("getCache", "无缓存 ，key不存在" + key);
				return "";
			}
		},

		getonerowstatus : function() {
			// -1 为删除的记录，0为未操作的记录，1为修改，2为新增，3为新增后删除的记录
			if (this.R.EVENT.ROWDATA) {
				var mTmp = $PublicFun.stringToInt(this.R.EVENT.ROWDATA['flag']);
				return mTmp;
			} else if (this.R.ROWDATA) {
				var mTmp = $PublicFun.stringToInt(this.R.ROWDATA['flag']);
				return mTmp;
			} else {
				$PublicFun.err("getonerowstatus", "获取失败没有当前记录信息,ROWDATA 不存在");
				return 0;
			}
		},
		getOneVarStruct : function(varName) {
			if (varName.startWith("var") || varName.startWith("tabc")) {
				return this.$locVar[varName];
			} else {
				return this.$pubVar[varName];
			}
		},
		
		/**
		 * 保存当前动态页面
		 * @method saveCurDyn
		 * @param flag {boolean} 保存成功后是否关闭当前动态页面
		 * @return {boolean}
		 */
		saveCurDyn : function(flag) {
			if (this.$instance.save()) {
				if (flag)
					this.closepage();
				return true;
			} else
				return false;
		},
		savecurdyn : function(flag) {
			return this.saveCurDyn(flag);
		},
		
		autocallendbyaftersave : function(vShowFlag, vShowNext) {
			vShowFlag = vShowFlag || 0;
			vShowNext = vShowNext || "";
			this.$instance.setAttribute($CONST.CTIEvent.CTI_AUTOCALLENDAFTERSAVE, {
				showFlag : vShowFlag,
				showNext : vShowNext
			})
			return 1;
		},
		autocallend : function(customerGuid, vShowFlag, vShowNext, eventComments) {
			return $PublicFun.autoCallEnd(this.$instance.project, vShowFlag, vShowNext, customerGuid, eventComments);
		},
		
		xmltobound : function(vData) {
			var returnObj = new BoundData();
			returnObj.parseXML(vData);
			return returnObj;
		},
		
		mergearraybycmd : function(mainGrid, toIndex, doCmdId) {
			toIndex = $PublicFun.stringToInt(toIndex);
			if (toIndex < 1) {
				$PublicFun.err("mergearraybycmd", "合并数据的目标列必须指定");
				return -1;
			}
			toIndex--;
			if (doCmdId == undefined) {
				$PublicFun.err("mergearraybycmd", "合并数据的命令组未指定");
				return -1;
			}
			var CmdList = this.$dynCmds["P" + doCmdId];
			if (CmdList) {
			} else {
				$PublicFun.err("mergearraybycmd", "命令组不存在");
				return -1;
			}
			mainGrid = mainGrid.trim().toLowerCase();
			var mMain = this.getOneVarStruct(mainGrid);
			if (mMain) {
				if (mMain.VT != 4) {
					$PublicFun.err("mergearraybycmd", "主数据源对象必须是表格变量");
					return -1;
				}
				var mMainData = $DynFun.getSystemValue(this, mMain.pM, mMain.pS, mMain.VT);
				if (mMainData instanceof Array) {
					var iCount = mMainData.length;
					for (var i = 0; i < iCount; i++) {
						var mOneR = mMainData[i];
						this.R['ROWDATA'] = mOneR;
						doOneCmdList(this, "mergearraybycmd do-P" + doCmdId, CmdList);
						if (this.R.GRID instanceof Array) {
							mOneR[toIndex] = this.R.GRID;
						} else {
							$PublicFun.log("mergearraybycmd", "第[" + i + "]行未返回表格数据");
						}
					}
				} else {
					$PublicFun.err("mergearraybycmd", "主数据源对象为空");
					return 0;
				}
			} else {
				$PublicFun.err("mergearraybycmd", "主数据源对象不存在");
				return -1;
			}
		},
		mergearray : function(mainGrid, mainKeyIndex, subGrid, subKeyIndex, toIndex) {
			mainKeyIndex = $PublicFun.stringToInt(mainKeyIndex);
			if (mainKeyIndex < 1) {
				$PublicFun.err("mergearray", "主数据源对应主键必须指定");
				return -1;
			}
			mainKeyIndex--;
			subKeyIndex = $PublicFun.stringToInt(subKeyIndex);
			if (subKeyIndex < 1) {
				$PublicFun.err("mergearray", "子数据源对应主键必须指定");
				return -1;
			}
			subKeyIndex--;
			toIndex = $PublicFun.stringToInt(toIndex);
			if (toIndex < 1) {
				$PublicFun.err("mergearray", "合并数据的目标列必须指定");
				return -1;
			}
			toIndex--;

			mainGrid = mainGrid.trim().toLowerCase();
			var mMain = this.getOneVarStruct(mainGrid);
			if (mMain) {
				if (mMain.VT != 4) {
					$PublicFun.err("mergearray", "主数据源对象必须是表格变量");
					return -1;
				}
				subGrid = subGrid.trim().toLowerCase();
				var mSub = this.getOneVarStruct(subGrid);
				if (mSub) {
					if (mSub.VT != 4) {
						$PublicFun.err("mergearray", "子数据源对象必须是表格变量");
						return -1;
					}
					var mMainData = $DynFun.getSystemValue(this, mMain.pM, mMain.pS, mMain.VT);
					var mSubData = $DynFun.getSystemValue(this, mSub.pM, mSub.pS, mSub.VT);
					return $PublicFun.mergeArray(mMainData, mainKeyIndex, mSubData, subKeyIndex, toIndex)
				} else {
					$PublicFun.err("mergearray", "子数据源对象不存在");
					return -1;
				}
			} else {
				$PublicFun.err("mergearray", "主数据源对象不存在");
				return -1;
			}
		},
		totransarray : function(gridproperty, fixCols, transCol, dataCol) {
			gridproperty = gridproperty.trim().toLowerCase();
			var mTr = this.getOneVarStruct(gridproperty);
			if (mTr) {
				if (mTr.VT != 4) {
					$PublicFun.err("totransarray", "数据源对象必须是表格变量");
					return [];
				}
				var mSourceData = $DynFun.getSystemValue(this, mTr.pM, mTr.pS, mTr.VT);
				return $PublicFun.toTransArray(mSourceData, fixCols, transCol, dataCol);
			} else {
				$PublicFun.err("totransarray", "数据源对象不存在");
				return [];
			}
		},

		woclear : function() {
			$PublicFun.$GI.wo = null;
			return 1;
		},
		woload : function(woId) {
			$PublicFun.$GI.wo = new $PublicFun.$ADVLIB.WO($E.staff.epidSql);
			return $PublicFun.$GI.wo.loadByID(this, woId);
		},
		wonew : function(objTypeId, CustomerId) {
			$PublicFun.$GI.wo = new $PublicFun.$ADVLIB.WO($E.staff.epidSql);
			return $PublicFun.$GI.wo.newWO(this, objTypeId, CustomerId);
		},
		wosave : function(notes) {
			if ($PublicFun.$GI.wo) {
				if ($PublicFun.$GI.wo.Flag > 0) {
					return $PublicFun.$GI.wo.saveWO(this, notes);
				} else {
					$PublicFun.log("wosave", "工单未初始化，不能保存")
					return -1;
				}
			} else {
				$PublicFun.log("wosave", "工单未初始化，不能保存")
				return -1;
			}
		},
		woclose : function(notes) {
			if ($PublicFun.$GI.wo) {
				if ($PublicFun.$GI.wo.Flag > 0) {
					return $PublicFun.$GI.wo.closeWO(this, notes);
				} else {
					$PublicFun.log("woclose", "工单未初始化，不能结案")
					return -1;
				}
			} else {
				$PublicFun.log("woclose", "工单未初始化，不能结案")
				return -1;
			}
		},
		wosend : function(notes, toStep, toGrp, toBy) {
			if ($PublicFun.$GI.wo) {
				if ($PublicFun.$GI.wo.Flag > 0) {
					return $PublicFun.$GI.wo.sendWO(this, notes, toStep, toGrp, toBy);
				} else {
					$PublicFun.log("wosave", "工单未初始化，不能下送")
					return -1;
				}
			} else {
				$PublicFun.log("wosave", "工单未初始化，不能下送")
				return -1;
			}
		},
		wocd : function(notes) {
			if ($PublicFun.$GI.wo) {
				if ($PublicFun.$GI.wo.Flag > 0) {
					return $PublicFun.$GI.wo.cdWO(this, notes);
				} else {
					$PublicFun.log("wocd", "工单未初始化，不能催单")
					return -1;
				}
			} else {
				$PublicFun.log("wocd", "工单未初始化，不能催单")
				return -1;
			}
		},
		wosetobj : function(objfield, objvalue) {
			if ($PublicFun.$GI.wo) {
				if ($PublicFun.$GI.wo.Flag > 0) {
					return $PublicFun.$GI.wo.setObjVal(objfield, objvalue);
				} else {
					$PublicFun.log("wosetobj", "工单未初始化，不能设objective字段值")
					return -1;
				}
			} else {
				$PublicFun.log("wosetobj", "工单未初始化，不能设objective字段值")
				return -1;
			}
		},
		wosetinfo : function(field, value) {
			if ($PublicFun.$GI.wo) {
				if ($PublicFun.$GI.wo.Flag > 0) {
					return $PublicFun.$GI.wo.setWOInfo(field, value);
				} else {
					$PublicFun.log("wosetinfo", "工单未初始化，不能设工单字段值")
					return -1;
				}
			} else {
				$PublicFun.log("wosetinfo", "工单未初始化，不能设工单字段值")
				return -1;
			}
		},
		wosettac : function(tbname, field, value) {
			if ($PublicFun.$GI.wo) {
				if ($PublicFun.$GI.wo.Flag > 0) {
					return $PublicFun.$GI.wo.setOtherTB(tbname, field, value);
				} else {
					$PublicFun.log("wosettac", "工单未初始化，不能设动态表值")
					return -1;
				}
			} else {
				$PublicFun.log("wosettac", "工单未初始化，不能设动态表值")
				return -1;
			}
		},
		setobjectivevalue : function(f, v) {
			try {
				this.$instance.objective.setValue(f, v);
			} catch (e) {
				$PublicFun.err("set OBJ", "设置Objective异常错误", e);
			}
		},
		setoblistfield : function(f, v) {
			try {
				this.$instance.objective.setObListValue(f, v);
			} catch (e) {
				$PublicFun.err("set OB Value", "设置字段异常错误", e);
			}
		},
		setobliststatus : function(flag, status, nexttime, by, grp) {
			try {
				this.$instance.objective.setOBListStatus(flag, status, nexttime, by, grp);
			} catch (e) {
				$PublicFun.err("set OB Status", "设置状态异常错误", e);
			}
		},
		
		// Fixed by kevin
		toggleClass : function(e, classname, expression) {
			CtlUtils.toggleClass(this.$runtime, e, classname, expression);
		},
		
		/**
		 * 自行某个控件的内容过滤方法
		 * @method filter
		 * @param ctl {string|object} 提供过滤内容的控件
		 * @param filterCtlId {string} 执行过滤的控件ID
		 */
		filter : function(ctl, filterCtlId) {
			CtlUtils.filter(this.$runtime, ctl, filterCtlId);
		},
		
		/**
		 * 执行某个控件的内容搜索方法
		 * @method search
		 * @param ctl {string|object} 提供过滤内容的控件
		 * @param searchCtlId {string} 执行过滤的控件ID
		 */
		search : function(ctl, searchCtlId) {
			CtlUtils.search(this.$runtime, ctl, searchCtlId);
		},
		
		setScript : function(e, script) {
			if (!e)
				return $PublicFun.err("setscript", "违例的函数语法：setScript(控件, 脚本)"), -1;
			if (!script) {
				script = e;
				e = this.R.CTRL;
			}
			CtlUtils.setScript(this.$runtime, e, script);
		},
		setscript : function(e, script) {
			this.setScript(e, script);
		},
		
		openLink : function(e) {
			window.open(e, '_system');
		},

		fmax : function() {
			var mMaxValue = undefined;
			for (var i = 0; i < arguments.length; i++) {
				if (mMaxValue == undefined) {
					mMaxValue = arguments[i];
				} else if (mMaxValue < arguments[i]) {
					mMaxValue = arguments[i];
				}
			}
			if (mMaxValue == undefined) {
				return "";
			} else {
				return mMaxValue;
			}

		},
		fmin : function() {
			var mMinValue = undefined;
			for (var i = 0; i < arguments.length; i++) {
				if (mMinValue == undefined) {
					mMinValue = arguments[i];
				} else if (mMinValue > arguments[i]) {
					mMinValue = arguments[i];
				}
			}
			if (mMinValue == undefined) {
				return "";
			} else {
				return mMinValue;
			}
		},
		/**
		 * 比较两个值，如果是字符串值则自动去除空格
		 * @param a {any} 值a
		 * @param b {any} 值b
		 * @param [force] {boolean} 是否使用强制匹配，默认为false
		 */
		equal : function(a, b, force) {
			if (a instanceof String)
				a = a.trim();
			if (b instanceof String)
				b = b.trim();
			if (force)
				return a === b;
			else
				return a == b;
		},
		getagefromidcard : function(vStr) {
			return $PublicFun.getAgeFromIdCard(vStr);
		},
		getbirthdayfromidcard : function(vStr) {
			return $PublicFun.getBirthdayFromIdCard(vStr);
		},
		getgenderfromidcard : function(vStr) {
			return $PublicFun.getGenderFromIdCard(vStr);
		},
		isvalididcard : function(vStr) {
			return $PublicFun.isValidIdCard(vStr);
		},
		numtofixstring : function(vStr) {
			return $PublicFun.numToFixStr(vStr);
		},
		buildsamestring : function(sameStr, times) {
			return $PublicFun.buildSameString(sameStr, times);
		},
		
		newguid : function() {
			return $PublicFun.newGuid();
		},
		guid : function() {
			return this.newguid();
		},
		/**
		 * Add by Kevin, Return FAKE 6 ID
		 * 
		 * @return {string}
		 */
		new6id : function() {
			return CmdUtils.ID6Gen();
		},
		id6 : function() {
			return this.new6id();
		},
		
		/**
		 * 打开一个动态页面
		 * 
		 * @param dynId {string} 动态页面ID
		 * @param tabName {string} TAB标签，为空时从动态页取默认名做为标签
		 * @param [parameter] {any} 打开动态页面时的入参json对象
		 * @param [keepOpen] {boolean} 是否不允许关闭，默认为false
		 * @param [veSupport] {boolean} 是否打开第二代动态页面
		 */
		openAddinDyn : function(dynId, tabName, parameter, keepOpen, veSupport) {
			return this.$runtime.project.openAddinDyn(dynId, tabName, parameter, keepOpen, 'DYN', veSupport);
		},
		openaddindyn : function(dynId, tabName, parameter, keepOpen, veSupport) {
			return this.openAddinDyn(dynId, tabName, parameter, keepOpen, veSupport);
		},

		/**
		 * 根据objective_guid和taskId打开工单3
		 * @param tabName {string} TAB标签
		 * @param oId {string} 市场活动guid
		 * @param taskId {string} 工单三任务guid
         * @returns {*}
         */
		openAddinWO3ByOId : function(tabName, oId, taskId) {
			return this.$runtime.project.openAddinWO3ByOId( 'AddinWO3', tabName, oId, taskId);
		},
		openaddinwo3byoid : function(tabName, oId, taskId){
			return this.openAddinWo3ByOId(tabName, oId, taskId);
		},

		/**
		 * 根据objectivetype_id打开工单3，可能是新建工单
		 * @param tabName {string} TAB标签
		 * @param otId {string} 市场活动类型id
         * @returns {*}
         */
		openAddinWO3ByOtId : function(tabName, otId) {
			// addinId = params.addinId;
			// tabName = params.tabName;
			// otId = params.otId;
			// menuId = params.menuId;
			// parameters = params.parameters;
			// wo3 = params.wo3;
			// customerGuid = params.customerGuid;
			// stepId = params.stepId;
			// dbPool = params.dbPool;
			// readonly = params.readonly;
			// alwaysNew = params.alwaysNew;
			return this.$runtime.project.openAddinWOByOtId({
				addinId: 'AddinWO3',
				tabName,
				otId,
				wo3: true
			});
		},
		openaddinwo3byotid : function(tabName, otId) {
			return this.openAddinWO3ByOtId(tabName, otId);
		},

		/**
		 * 设置当前动态页面的归属人
		 * 
		 * @param owner
		 *            {string} 归属人
		 * @param inclusive
		 *            {boolean} 独占性
		 */
		setDynOwner : function(owner, inclusive) {
			var a = this.$runtime.instance;
			a.owner = owner;
			a.ownerInclusive = inclusive;
		},
		setdynowner : function(owner, inclusive) {
			this.setdynowner(owner, inclusive);
		},
		
		/**
		 * 打开一个插件
		 * @method openPlugin
		 * @param name {string} 标签名称
		 * @param pluginId {string} 插件ID，参考sysc_addins表
		 * @param pluginParam {object} 插件入参，参考插件规范
		 * @param parameters {object} 方法入参，参考插件规范
		 * @param keepOpen {boolean} 标签是否不可关闭
		 */
		openPlugin : function(name, pluginId, pluginParams, parameters, keepOpen) {
			window.$E.openPlugin(name, this.$project, pluginId, pluginParams, parameters, keepOpen);
		},

		/**
		 * 在指定的面版容器中调用插件
		 * 
		 * @param ctl
		 *            {string | object} 目标控件ID或者控件对象
		 * @param addin
		 *            {string} 插件所在的组件ID
		 * @param addinParam
		 *            {any} 插件所在的组件参数
		 * @param parameters
		 *            {any} 插件运行入参
		 */
		embPlugin : function(ctl, addin, addinParam, parameters) {
			var inst = this.$instance;
			if ($.type(ctl) == 'string')
				ctl = this.ctl(ctl);
			if (ctl) {
				$E.embPlugin(ctl, this.$instance.project, addin, addinParam, parameters, function(plugin) {
					if (plugin) {
						plugin.embedInstance = inst;
						inst.plugins.push(plugin);
					}
					else
						throw new Error('创建嵌入式插件失败：' + addin)
				});
			}
		},
		embplugin : function(ctl, addin, addinParam, parameters) {
			this.embPlugin(ctl, addin, addinParam, parameters);
		},
		
		/**
		 * 在指定的容器控件中打开一个工单
		 * @method embWo3
		 * @param ctl {string || object} 指定容器控件的ID或者对象
		 * @param woParams {object} 包括了：
		 * 		otId {string} 工单MAPID，如果是新建工单，需要入参工单ID
		 * 		oId {string} ObjectiveGuid, 打开一个已经存在的工单，需要入参ObjectiveGuid，此时woId可入参空
		 * 		taskId {string} 工单节点步骤ID, 打开一个已经存在的工单时有效
		 * 		[notifyId] {string} 工单提醒id
		 * 		[readonly] {boolean} 是否是只读打开，如果是只读打开就不会校验是否重复打开
		 * @param [parameters] {object} 入参环境
		 */
		embWo3 : function(ctl, woParams, parameters) {
			if ($.type(ctl) == 'string')
				ctl = this.ctl(ctl);
			if (ctl) {
				if (!$.isFunction(ctl.getContainer))
					$F.err('Cmd - embWo3', '无法在非容器控件中打开工单 - ' + ctl.type);
				else {
					var wo = this.$project.embWo3(ctl.getContainer(), woParams, {
						FRAMEDATA : this.$runtime.data,
						PARAMS: parameters
					});
					if (wo) {
						this.$instance.wos.push(wo);
						wo.rootInstance = this.$instance;
					}
				}
			}
		},

		dateadd : function(unit, d, len) {
			try {
				var inDate = $F.parseDate(d);
				var inInt = inDate.valueOf();
				unit = unit.toLowerCase();
				if (unit == "year") {
					var y1 = inDate.getFullYear() + len;
					var y2 = inDate.getMonth() + 1;
					var y3 = inDate.getDate();
					if (d.trim().length > 11) {
						var y4 = inDate.getHours();
						var y5 = inDate.getMinutes();
						var y6 = inDate.getSeconds();
						return y1 + '-' + (y2.toString().length > 1 ? y2 : "0" + y2) + '-' + (y3.toString().length > 1 ? y3 : "0" + y3) + ' ' + (y4.toString().length > 1 ? y4 : "0" + y4) + ':' + (y5.toString().length > 1 ? y5 : "0" + y5) + ':' + (y6.toString().length > 1 ? y6 : "0" + y6);
					} else {
						return y1 + '-' + (y2.toString().length > 1 ? y2 : "0" + y2) + '-' + (y3.toString().length > 1 ? y3 : "0" + y3);
					}

				} else if (unit == "month") {
					var y1 = inDate.getFullYear();
					var y2 = inDate.getMonth() + 1;
					for (var i = 0; i < len; i++) {
						y2++;
						if (y2 > 12) {
							y1++;
							y2 = 1;
						}
					}
					var y3 = inDate.getDate();
					if (d.trim().length > 11) {
						var y4 = inDate.getHours();
						var y5 = inDate.getMinutes();
						var y6 = inDate.getSeconds();
						return y1 + '-' + (y2.toString().length > 1 ? y2 : "0" + y2) + '-' + (y3.toString().length > 1 ? y3 : "0" + y3) + ' ' + (y4.toString().length > 1 ? y4 : "0" + y4) + ':' + (y5.toString().length > 1 ? y5 : "0" + y5) + ':' + (y6.toString().length > 1 ? y6 : "0" + y6);
					} else {
						return y1 + '-' + (y2.toString().length > 1 ? y2 : "0" + y2) + '-' + (y3.toString().length > 1 ? y3 : "0" + y3);
					}
				} else if (unit == "day") {
					inInt += len * (24 * 60 * 60 * 1000);
					inDate = new Date(inInt);
					if ($.type(d) !== 'string' || d.trim().length > 11) {
						return inDate.format();
					} else {
						return inDate.format();
					}
				} else if (unit == "hour") {
					inInt += len * (60 * 60 * 1000);
				} else if (unit == "minute") {
					inInt += len * (60 * 1000);
				} else if (unit == "second") {
					inInt += len * 1000;
				} else {
					$PublicFun.err("dateadd", "错误的时间单位:" + unit);
					return d;
				}
				inDate = new Date(inInt);
				return inDate.format();
			} catch (e) {
				$PublicFun.err("dateadd", '日期操作失败', e);
				return d;
			}
		},
		datediff : function(d1, d2) {
			var a1 = $F.parseDate(d1), a2 = $F.parseDate(d2);
			return (a2.getTime() - a1.getTime()) / 1000;
		},
		
		closePage : function() {
			this.$instance.project.tabClose(this.$instance.id);
		},
		closepage : function() {
			this.closePage();
		},

//		doregmessage : function(msgType, callbackCmdId) {
//			console.error('doregmessage已废弃，请使用Event.register')
//			this.Event.register(msgType, callbackCmdId)
//		},
//
//		doremovemessage : function(Flag, msgType) {
//			console.error('doremovemessage已废弃，请使用Event.remove')
//			if (Flag == 1) {
//				this.$instance.project.events.remove(this.$instance.id, msgType);
//			} else {
//				this.$instance.project.events.remove(this.$instance.id);
//			}
//		},
//		dofiremessage : function(msgType) {
//			console.error('dofiremessage已废弃，请使用Event.fire')
//			this.Event.fire(msgType);
//		},
		replacestr : function(source, replace, to) {
			return $DynFun.replaceStr(source, replace, to, 0);
		},
		lockdata : function(MdlName, MdlId, ToVar) {
			var mRs = $F.ajaxSync("JSGenerateServlet2", {
				token : this.$token,
				dbPool : "",
				name : "System.Locked",
				mainId : MdlName || "",
				subId : MdlId || ""
			}, this.$digest);
			if (mRs) {
				if (mRs.code > 0) {
					return mRs.code;
				} else {
					if (mRs.code == -2) {
						if (ToVar != undefined) {
							if (ToVar) {
								this.R[ToVar.toUpperCase()] = mRs.message;
							}
						}
					}
					// $PublicFun.err("lockdata","加锁失败，返回异常:"+mRs.message);
					return mRs.code;
				}
			} else {
				$PublicFun.err("lockdata", "加锁失败，返回异常");
				return -1;
			}
		},
		unlockdata : function(MdlName, MdlId) {
			var mRs = $F.ajaxSync("JSGenerateServlet2", {
				token : this.$token,
				dbPool : "",
				name : "System.unLocked",
				mainId : MdlName || "",
				subId : MdlId || ""
			}, this.$digest);
			if (mRs) {
				return mRs.code;
			} else {
				return -1;
			}
		},
		checklockdata : function(MdlName, MdlId, ToVar) {
			var mRs = $F.ajaxSync("JSGenerateServlet2", {
				token : this.$token,
				dbPool : "",
				name : "System.CheckLocked",
				mainId : MdlName || "",
				subId : MdlId || ""
			}, this.$digest);
			if (mRs) {
				if (mRs.code >= 0) {
					return mRs.code;
				} else {
					if (mRs.code == -2) {
						if (ToVar != undefined) {
							if (ToVar) {
								this.R[ToVar.toUpperCase()] = mRs.message;
							}
						}
					}
					return mRs.code;
				}
			} else {
				$PublicFun.err("checklockdata", "加锁失败，返回异常");
				return -1;
			}

		},

		getdbtype : function(dbPoolStr) {
			var mRs = $F.ajaxSync("DBInfo", {
				token : this.$token,
				dbPool : dbPoolStr || ''
			}, this.$digest);
			if (mRs) {
				if (mRs.code > -1) {
					return mRs.value;
				} else {
					$PublicFun.err("getdbtype", "获取数据库类型失败：" + mRs.message);
					return "";
				}
			} else {
				$PublicFun.err("getdbtype", "获取数据库类型失败,异常错误 ");
				return "";
			}
		},
		
		getdynid : function() {
			return this.$instance.dynId;
		},

		averagegrid : function(gridvar, averageNum, averageByCol, toCol, decLen, whereId, whereKey) {
			var mOneVar = this.getOneVarStruct(gridvar.toLowerCase());
			if (mOneVar == undefined) {
				$PublicFun.err("averagegrid", "平均分配，[" + gridvar + "]属性不存在");
				return -1;
			} else {
				averageNum = averageNum || 0;
				// console.log(averageNum);
				if (averageNum == 0) {
					$PublicFun.err("averagegrid", "待平均分配数为0，不能分配");
					return -1;
				}
				if (mOneVar.VT == 4) {
					averageByCol = (averageByCol || 0);
					averageByCol--;
					if (averageByCol < 0) {
						$PublicFun.err("averagegrid", "平均分配，跟据分配列对应错误");
						return -1;
					}
					toCol = toCol || 0;
					toCol--;
					if (toCol < 0) {
						$PublicFun.err("averagegrid", "平均分配，回写分配数据列对应错误");
						return -1;
					}
					decLen = decLen || 0;
					whereId = whereId || 0;
					whereId--;
					var mGridValue = $DynFun.getSystemValue(this, mOneVar.pM, mOneVar.pS, mOneVar.VT);
					// console.log(mGridValue);
					// console.log(mGridValue instanceof Array);
					if (mGridValue instanceof Array) {
						if (mGridValue.length == 0) {
							$PublicFun.err("averagegrid", "平均分配，[" + gridvar + "]表格无数据");
							return -1;
						}
						var mDataCount = 0;
						if (whereId >= 0) {
							whereKey = (whereKey || "").toLowerCase();
							for (var i = 0; i < mGridValue.length; i++) {
								var mTmpOne = mGridValue[i];
								if ((mTmpOne[whereId] || "").toLowerCase() == whereKey) {
									mDataCount += $PublicFun.stringToFloat(mTmpOne[averageByCol]);
								}
							}
							$PublicFun.log("avarage", "Where Count Value:" + mDataCount);
							var mNextData = averageNum, mLastObj;
							for (var i = 0; i < mGridValue.length; i++) {
								var mTmpOne = mGridValue[i];
								if ((mTmpOne[whereId] || "").toLowerCase() == whereKey) {
									mLastObj = mTmpOne;
									var mAvarData = $PublicFun.round(averageNum / mDataCount * $PublicFun.stringToFloat(mTmpOne[averageByCol]), decLen);
									if (mNextData - mAvarData > 0) {
										mNextData -= mAvarData;
									} else {
										mAvarData = mNextData;
										mNextData = 0;
									}
									$PublicFun.log("avarage", "Where Set Col:" + toCol + " Value:" + mAvarData);
									mTmpOne[toCol] = mAvarData;
								}
							}
							if (mNextData != 0) {
								if (mLastObj) {
									mLastObj[toCol] = (mLastObj[toCol] || 0) + mNextData;
								}
							}
						} else {
							for (var i = 0; i < mGridValue.length; i++) {
								var mTmpOne = mGridValue[i];
								mDataCount += $PublicFun.stringToFloat(mTmpOne[averageByCol]);
							}
							$PublicFun.log("avarage", " Count Value:" + mDataCount);
							var mNextData = averageNum, mLastObj;
							for (var i = 0; i < mGridValue.length; i++) {
								var mTmpOne = mGridValue[i];
								mLastObj = mTmpOne;
								var mAvarData = $PublicFun.round(averageNum / mDataCount * $PublicFun.stringToFloat(mTmpOne[averageByCol]), decLen);
								if (mNextData - mAvarData > 0) {
									mNextData -= mAvarData;
								} else {
									mAvarData = mNextData;
									mNextData = 0;
								}
								$PublicFun.log("avarage", " Set Col:" + toCol + " Value:" + mAvarData);
								mTmpOne[toCol] = mAvarData;
							}
							if (mNextData != 0) {
								if (mLastObj) {
									mLastObj[toCol] = (mLastObj[toCol] || 0) + mNextData;
								}
							}
						}
						this.refreshgrid(gridvar);
						return 1;
					} else {
						$PublicFun.err("averagegrid", "平均分配，[" + gridvar + "]表格无数据");
						return -1;
					}
				}
			}
			// AverageOneColData(vTargetData:Object,vAverageData:Number,vAverageByCol:int,vToCol:int,vDecLen:int,vKeyID:String=null,vKeyWhereCol:int=0,vKeyValue:String=""):int{
		},
		docirclecommand : function(gridvar, cmdId) {
			if (gridvar instanceof Array) {
				return doOneOther_98_1(this, gridvar, (cmdId + '').trim(), null, "docirclecommand");
			} else {
				var mOneVar = this.getOneVarStruct(gridvar.toLowerCase());
				if (mOneVar == undefined) {
					$PublicFun.err("docirclecommand", "执行循环命令集错误，[" + gridvar + "]属性不存在");
					return -1;
				} else {
					if (mOneVar.VT == 4) {
						var mCircleValue = $DynFun.getSystemValue(this, mOneVar.pM, mOneVar.pS, mOneVar.VT);
						cmdId = (cmdId + "").trim();
						return doOneOther_98_1(this, mCircleValue, cmdId, null, "docirclecommand");
					} else {
						$PublicFun.err("docirclecommand", "执行循环命令集错误，循环条件为空 ，属性不为记录集:" + gridvar);
						return -1;
					}
				}
			}
		},
		docirclepublic : function(gridvar, pubCmdId) {
			var mOneVar = this.getOneVarStruct(gridvar.toLowerCase());
			if (mOneVar == undefined) {
				$PublicFun.err("docirclepublic", "执行循环命令集错误，[" + gridvar + "]属性不存在");
				return -1;
			} else {
				if (mOneVar.VT == 4) {
					var mCircleValue = $DynFun.getSystemValue(this, mOneVar.pM, mOneVar.pS, mOneVar.VT);
					if (mCircleValue) {
						var mFlag = 0;
						pubCmdId = (pubCmdId + "").trim();
						if (pubCmdId.substring(0, 1).toLowerCase() == "f") {
							mFlag = 1;
							pubCmdId = pubCmdId.substring(1);
						}
						var CmdList = $D.getPCmd(this.$runtime, pubCmdId);
						if (CmdList) {
							if (mFlag == 0) {
								doOneOther_98_1_1(this, pubCmdId, mCircleValue, CmdList, {}, "docirclepublic", 1);
							} else {
								doOneOther_98_1_1_F(this, pubCmdId, mCircleValue, CmdList, {}, "docirclepublic", 1);
							}
							return 1;
						} else {
							return -1;
						}
					}
				} else {
					$PublicFun.err("docirclepublic", "执行循环命令集错误，循环条件为空 ，属性不为记录集:" + gridvar);
					return -1;
				}
			}
		},
		
		/**
		 * 执行动态页面主结构的命令组
		 * @param cmdId {string | integer} 命令号
		 * @param parameters {object} 入参数据，JSON格式
		 * @return {integer} -1为调用失败，其他为执行命令组的行数
		 */
		doInstanceCommand : function(cmdId, parameters) {
			var cmdList = this.$instance.runtime.struct.CmdList['P' + cmdId];
			if (cmdList) {
				this.$instance.doCmd('P' + cmdId, parameters);
				return cmdList.length;
			} else
				return -1;
		},
		
		/**
		 * 执行命令组
		 * @param cmdId {string | integer} 命令号
		 * @return {integer} -1为调用失败，其他为执行命令组的行数
		 */
		doCommand : function(cmdId) {
//			var cmdList = this.$dynCmds["P" + cmdId];
//			if (cmdList) {
//				doOneCmdList(this, "Command-P" + cmdId, cmdList, this.refreshQueue, '', 1);
//				return cmdList.length;
//			} else {
//				return -1;
//			}
			this.$instance.doCmd('P' + cmdId, this.R, this.$runtime);
		},
		docommand : function(cmdId) {
			this.doCommand(cmdId);
		},
		
		/**
		 * 执行全局命令组
		 * @param cmdId {string | integer} 命令号
		 * @param parameters {object} 入参数据，JSON格式
		 * @return {integer} -1为调用失败，其他为执行命令组的行数
		 */
		doPublicCommand : function(cmdId) {
			var cmdList = window.$D.getPCmd(this.$runtime, cmdId);
			if (cmdList) {
				doOneCmdList(this, "Command-G" + cmdId, cmdList, undefined, cmdId);
				return cmdList.length;
			} else {
				return -1;
			}
		},
		dopublic : function(cmdId) {
			return this.doPublicCommand(cmdId);
		},
		
		setcontrolfocus : function(ctlId) {
			CtlUtils.ctlFocus(ctlId, this.$runtime);
		},

		setnextcontrolfocus : function(ctlId) {
			CtlUtils.ctlNextFocus(ctlId, this.$runtime);
		},
		setprecontrolfocus : function(ctlId) {
			CtlUtils.ctlPrevFocus(ctlId, this.$runtime);
		},

		currentday : function() {
			var mTmp = $PublicFun.now();
			if (mTmp.length >= 8) {
				return mTmp.substr(8, 2);
			} else {
				return "";
			}
		},
		currenthour : function() {
			var mTmp = $PublicFun.now();
			if (mTmp.length >= 13) {
				return mTmp.substr(11, 2);
			} else {
				return "";
			}
		},
		currentminute : function() {
			var mTmp = $PublicFun.now();
			if (mTmp.length >= 16) {
				return mTmp.substr(14, 2);
			} else {
				return "";
			}
		},
		currentmonth : function() {
			var mTmp = $PublicFun.now();
			if (mTmp.length >= 7) {
				return mTmp.substr(5, 2);
			} else {
				return "";
			}
		},
		currentsecond : function() {
			var mTmp = $PublicFun.now();
			if (mTmp.length >= 19) {
				return mTmp.substr(17, 2);
			} else {
				return "";
			}
		},
		currentyear : function() {
			var mTmp = $PublicFun.now();
			if (mTmp.length >= 4) {
				return mTmp.substr(0, 4);
			} else {
				return "";
			}
		},
		currentweekday : function(d) {
			if (d == undefined) {
				d = $PublicFun.now();
			}
			var mLen = d.length;
			if (mLen >= 10) {
				var mYear = parseInt(d.substr(0, 4));
				var mM = parseInt(d.substr(5, 2));
				var mD = parseInt(d.substr(8, 2));
				var date = new Date();
				date.setFullYear(mYear);
				date.setMonth(mM - 1);
				date.setDate(mD);
				return date.getDay();
			} else {
				$PublicFun.err("Express", "非法日期求weekday:" + d);
				return -1;
			}
		},
		replace : function(source, from, to) {
			return source.replace2(from, to);
		},
		ceil : function(v) {
			return Math.ceil(v);
		},
		round : function(v) {
			return Math.round(v);
		},
		rand : function(v) {
			v = $PublicFun.stringToInt(v);
			return Math.round(Math.random() * v);
		},
		iif : function(e, t, f) {
			if (e) {
				return t;
			} else {
				return f;
			}
		},
		get : function(e) {
			return e;
		},
		json : function(e) {
			return e;
		},
		isdigitstring : function(s) {
			for (var i = 0; i < s.length; i++) {
				var temp = s.charAt(i);
				if (temp < '0' || temp > '9') {
					return false;
				}
			}
			return true;
		},
		trim : function(s) {
			try {
				return s.replace(/(^\s*)|(\s*$)/g, '');
			} catch (e) {
				return s;
			}
		},
		rtrim : function(s) {
			try {
				return s.replace(/\s*$/, '');
			} catch (e) {
				return s;
			}
		},
		isempty : function(s) {
			if (s == undefined) {
				return true;
			} else if (s == null) {
				return true;
			} else if (s.trim().length < 1) {
				return true;
			}
			return false;
		},
		equals : function(s1, s2) {
			if (s1.trim() == s2.trim()) {
				return true;
			}
			return false;
		},
		equalsignorecase : function(s1, s2) {
			if (s1.trim().toUpperCase() == s2.trim().toUpperCase()) {
				return true;
			}
			return false;
		},
		ischinese : function(s) {
			var s = s.replace(/(^\s*)|(\s*$)/g, '');
			if (!(/^[\u4E00-\uFA29]*$/.test(s) && (!/^[\uE7C7-\uE7F3]*$/.test(s)))) {
				return false;
			}
			return true;
		},
		isemail : function(s) {
			if (/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(s)) {
				return true
			}
			return false;
		},
		isint : function(s) {
			if (/^-?\d+$/.test(s)) {
				return true;
			}
			return false;
		},
		isfloat : function(s) {
			if (/^(-?\d+)(\.\d+)?$/.test(s)) {
				return true;
			}
			return false;
		},
		isip : function(s) {
			var reg = /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/;
			if (reg.test(s)) {
				return true;
			}
			return false;
		},
		stringcompare : function(vFirst, vSecond) {
			if (vFirst.trim() > vSecond.trim()) {
				return 1;
			} else if (vFirst.trim() < vSecond.trim()) {
				return -1;
			} else {
				return 0;
			}
		},
		instr : function(v1, v2) {
			if (v1.toUpperCase().indexOf(v2.toUpperCase()) >= 0) {
				return true;
			} else {
				return false;
			}
		},
		capitalize : function(src) {
			if (isNaN(src)) {
				return src.substr(0, 1).toUpperCase() + src.substr(1);
			} else {
				return src;
			}
		},
		tolower : function(s) {
			return s.toLowerCase();
		},
		ucase : function(s) {
			return s.toUpperCase();
		},
		encodeutf : function(src) {
			return encodeURIComponent(src);
		},
		decodeutf : function(src) {
			return decodeURIComponent(src);
		},
		xmlencode : function(src) {
			if (src == undefined) {
				return "";
			} else {
				src = src.replace(/&/ig, "&amp;").replace(/</ig, "&lt;").replace(/>/ig, "&gt;").replace(/"/ig, "&quot;").replace(/'/ig, "&apos;").replace(/\x0D/g, "&#x000D;");
				return src;
			}
		},
		xmldecode : function(src) {
			if (src == "") {
				return "";
			} else {
				src = src.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&apos;/g, "'").replace(/&#x000D;/g, "\n");
				return src;
			}
		},
		abs : function(src) {
			if (!isNaN(src)) {
				var v = $PublicFun.stringToFloat(src);
				if (v > 0) {
					return v;
				} else {
					return v * (-1);
				}
			} else {
				return 0;
			}
		},
		getcustomerinfo : function(name) {
			return $DynFun.getCustInfo(this, name);
		},
		setcustomerinfo : function(name, value) {
			$DynFun.setCustInfo(this, name, value);
			return 1
		},
		
		/**
		 * 判断当前实例客户是否相同与框架客户
		 * @return {boolean}
		 */
		isProjectCustomer : function() {
			return (this.$instance.customer.getValue('customer_guid') == this.$project.customer.getValue('customer_guid'))
		},
		isprojectcustomer : function() {
			return this.isProjectCustomer();
		},		
		
		/**
		 * 保存当前框架中的客户资料
		 * 注意，本方法并非针对当前实例中的客户进行保存，而是针对框架客户进行保存。
		 * 当且仅当实例客户与框架客户相同时，改方法即等效于保存实例客户资料
		 */
		saveCustomer : function() {
			var proj = this.$project;
			return new Promise(function(resolve, reject){
				proj.customer.save(function(customerGuid) {
					if (proj.customer.getProperty("customer_guid") != customerGuid) {
						proj.setCurrentCustomerByGuid(customerGuid);
					}
					resolve();
				}, function(){
					reject();
				}, null, true);
			});
		},
		savecustomer : function() {
			return this.saveCustomer();
		},
		
		/**
		 * 设置当前框架客户
		 * @param customerGuid {string} 客户GUID
		 */
		setCurrentCustomer : function(customerGuid) {
			this.$project.setCurrentCustomerByGuid(customerGuid);
		},
		setcurrentcustomer : function(customerGuid) {
			this.setCurrentCustomer(customerGuid);
		},
		
		setobjvalue : function(name, value) {
			this.$instance.objective.setValue(name, value);
			return 1;
		},
		getobjvalue : function(name) {
			return this.$instance.objective.getValue(name);
		},
		urlencode : function(s) {
			return encodeURIComponent(s);
		},
		processaddvalue : function(vValue) {
			if ($PublicFun.$PR.UseFlag == 1) {
				if (vValue == undefined) {
					vValue = 0;
				}
				vValue = $PublicFun.stringToFloat(vValue);
				if (vValue == 0) {
					$PublicFun.$PR.CurValue++;
				} else {
					$PublicFun.$PR.CurValue = vValue;
				}
				if ($PublicFun.$PR.MaxValue) {
					var mTmpValue = $PublicFun.$PR.CurValue / $PublicFun.$PR.MaxValue * 100;
					$PublicFun.$PR.ProcessObj.value(mTmpValue);
					return 1;
				} else {
					$PublicFun.$PR.ProcessObj.value(0);
					return -1;
				}
			} else {
				return -1;
			}
		},
		initprocessbar : function(vOpenFlag, vMaxValue, vWidth, vTitle) {
			if (vOpenFlag == 1) {
				if ($PublicFun.$PR.UseFlag == 1) {
					$F.info("进度条使用中,不能新建进度条");
					return -1;
				}
				if (vWidth) {
					vWidth = $PublicFun.stringToInt(vWidth);
					if (vWidth) {
					} else {
						vWidth = 300;
					}
				} else {
					vWidth = 300;
				}
				$PublicFun.$PR.UseFlag = 1;
				try {
					$PublicFun.$PR.ProcessObj = $F.progress({
						width : vWidth,
						title : vTitle
					})
				} catch (e) {
					$PublicFun.err("initprocessbar", "进度条处理失败", e)
				}
				if ($PublicFun.$PR.ProcessObj) {
					$PublicFun.$PR.MaxValue = vMaxValue;
					$PublicFun.$PR.CurValue = 0;
					$PublicFun.$PR.ProcessObj.value(0);
					return 1;
				} else {
					$PublicFun.$PR.UseFlag = 0;
					return -1
				}
			} else {
				if ($PublicFun.$PR.UseFlag == 1) {
					$PublicFun.$PR.ProcessObj.finish();
					$PublicFun.$PR.UseFlag = 0;
					return 1;
				} else {
					return -1;
				}
			}
		},
		todouble : function(v) {
			return $PublicFun.stringToFloat(v);
		},
		tolong : function(v) {
			return $PublicFun.stringToInt(v);
		},
		substrmid : function(s, findstring) {
			var index = s.indexOf(findstring);
			if (index >= 0) {
				return s.substr(index);
			} else {
				return "";
			}
		},
		substrright : function(s, findstring) {
			var index = s.indexOf(findstring);
			if (index >= 0) {
				return s.substr(index + findstring.length);
			} else {
				return "";
			}
		},
		tostring : function(s) {
			return s || '';
		},
		substr : function(s, startpos, len) {
			return s.substr(startpos, len);
		},
		substrindex : function(s, findstring) {
			return s.indexOf(findstring);
		},
		strleft : function(s, len) {
			return s.substr(0, len);
		},
		strright : function(s, len) {
			var m = s.length;
			if (m <= len) {
				return s;
			} else {
				return s.substring(m - len);
			}
		},
		strlen : function(s) {
			return s.length;
		},
		substrleft : function(s, findstring) {
			var index = s.indexOf(findstring);
			if (index >= 0) {
				return s.substr(0, index);
			} else {
				return "";
			}
		},
		getloginkey : function() {
			return this.$token;
		},
		stringtosqlin : function(s) {
			var mArray = s.split(","), mTmp = "";
			var iCount = mArray.length;
			for (var i = 0; i < iCount; i++) {
				mTmp += ",'" + mArray[i] + "'";
			}
			if (mArray.length > 0) {
				return mTmp.substring(1);
			} else {
				return "";
			}
		},
		now : function() {
			return $PublicFun.now();
		},
		getdbtime : function() {
			return $PublicFun.now();
		},
		
		
		// --------------------------------脚本命令区-----------------------
		setValue : function(propertyName, value) {
			var property = this.$instance.getProperty(propertyName, this.$runtime);
			if (property) {
				var refrshObj = {};
				refrshObj[propertyName] = $DynFun.refreshObjNew($DynFun.setSystemVar(this, property, value));
				this.$callback(refrshObj, this.$runtime);
				return true;
			} else {
				$PublicFun.err("setValue", "变量不存在:" + propertyName);
				return false;
			}
		},
		setvalue : function(propertyName, value) {
			return this.setValue(propertyName, value);
		},
		getValue : function(propertyName) {
			var mTr = this.getOneVarStruct(propertyName.trim().toLowerCase());
			if (mTr) {
				return $DynFun.getSystemValue(this, mTr.pM, mTr.pS, mTr.VT);
			} else {
				$PublicFun.err("getvalue", "变量不存在:" + propertyName);
				return "";
			}
		},
		getvalue : function(propertyName) {
			return this.getValue(propertyName);
		},
		val : function(propertyName, value) {
			if (value == undefined)
				return this.getValue(propertyName);
			else
				this.setValue(propertyName, value);
		},

		/**
		 * 通知控件刷新变量
		 * @param propertyName {string} 变量名称
		 */
		refresh : function(propertyName, data) {
			if ($.type(propertyName) == 'string' ) {
				propertyName = propertyName.toLowerCase();
				var mOne = this.getOneVarStruct(propertyName);
				if (mOne) {
					var RefrshObj = {};
					if (this.refreshQueue[propertyName]) {
						RefrshObj[propertyName] = (data ? data : this.refreshQueue[propertyName]);
						delete this.refreshQueue[propertyName];
					} else {
						RefrshObj[propertyName] = (data ? data : $DynFun.refreshObjNew($DynFun.getSystemValue(this, mOne.pM, mOne.pS, mOne.VT)));
					}
					this.$callback(RefrshObj, this.$runtime);
				} else {
					$PublicFun.err("refresh", "变量不存在: " + propertyName);
				}
			} else {
				this.$callback(this.refreshQueue, this.$runtime);
				for(var key in this.refreshQueue)
					delete this.refreshQueue[key];
			}
		},
		
//		findonerow : function() {
//			console.error('findonerow已废弃，请使用Grid.find');
//			if (arguments.length < 3) {
//				$PublicFun.err("findrow one row", "传入参数错误");
//				return -1;
//			}
//			var sr = arguments[0];
//			var row = $PublicFun.stringToInt(arguments[1]);
//			var FindCount = arguments.length - 2;
//			row = row - 1;
//			if (row < 0) {
//				row = 0;
//			}
//			if (FindCount % 2 != 0) {
//				$PublicFun.err("findrow one row", "传入参数错误,必须是列号与查找到成对出现");
//				return -1;
//			}
//			if (sr) {
//				var mSr = this.getOneVarStruct(sr.toLowerCase());
//				if (mSr) {
//					if (mSr.VT != 4) {
//						$PublicFun.err("findrow One Col", " 源对象必须是表格变量");
//						return -1;
//					}
//					var mSourceData = $DynFun.getSystemValue(this, mSr.pM, mSr.pS, mSr.VT);
//					if (mSourceData instanceof Array) {
//						var iRowCount = mSourceData.length;
//						for (var r = row; r < iRowCount; r++) {
//							for (var i = 0; i < FindCount; i = i + 2) {
//								var mTmpCompare = mSourceData[r][arguments[i + 2] - 1];
//								if (arguments[i + 3] != mTmpCompare) {
//									break;
//								}
//							}
//							if (i >= FindCount) {
//								return r + 1;
//							}
//						}
//						return -1;
//					} else {
//						return -1;
//					}
//				} else {
//					$PublicFun.err("find one col", "表格查找行失败：源表格变量不存在 name:" + sr);
//					return -1;
//				}
//			} else {
//				$PublicFun.err("findrow one Col", "表格查找行失败：源表格变量为NULL");
//				return -1;
//			}
//		},
//		refreshgrid : function(pName) {
//			console.error('refreshgrid已经废弃，请使用refresh方法');
//			this.refresh(pName);
//		},
//		
//		/**
//		 * 移除列表项中的某行记录
//		 * 
//		 * @param ctlId
//		 *            {any} 控件ID或者对象
//		 * @param rowNo
//		 *            {int} 行号，从0开始
//		 * @returns {int}
//		 */
//		gridremove : function(ctlId, rowNo) {
//			console.error('gridremove已废弃，请使用CtlUtils.xitemRemove(sandbox, ctlId, row)');
//			return CtlUtils.xitemRemove(this.$runtime, ctlId, rowNo) ? 1 : 0;
//		},
//
//		copyonerow : function(sr, tr, row) {
//			console.error('copyonerow已废弃，请使用Grid.copyRow');
//			if (sr) {
//				if (tr) {
//					if (row != undefined) {
//						row = $PublicFun.stringToInt(row) - 1;
//						if (row < 0) {
//							$PublicFun.err("Copy One Row", "错误的行号，行号必须大于0 现在行号：" + (row + 1));
//							return -1;
//						}
//						var mSr = this.getOneVarStruct(sr.toLowerCase());
//						if (mSr) {
//							if (mSr.VT != 4) {
//								$PublicFun.err("Copy One Row", "源对象必须是表格变量");
//								return -1;
//							}
//							var mSourceData = $PublicFun.getSystemValue(this, mSr.pM, mSr.pS, mSr.VT);
//							if (mSourceData instanceof Array) {
//								if (mSourceData.length > row) {
//									// 继续运行
//								} else {
//									$PublicFun.err("Copy One Row", "COPY 行号超过源对象记录数");
//									return -1;
//								}
//							} else {
//								$PublicFun.err("Copy One Row", "源对象为空");
//								return -1;
//							}
//							var mTr = this.getOneVarStruct(tr.toLowerCase());
//							if (mTr) {
//								if (mTr.VT != 4) {
//									$PublicFun.err("Copy One Row", "目标对象必须是表格变量");
//									return -1;
//								}
//								var mTrData = $PublicFun.getSystemValue(this, mTr.pM, mTr.pS, mTr.VT);
//								var mOneRow = mSourceData[row];
//								if (mTrData instanceof Array) {
//									mTrData.push(mOneRow.slice(0));
//								} else {
//									mTrData = $PublicFun.setSystemVar(this, mTr, []);
//									mTrData.push(mOneRow.slice(0));
//								}
//								return 1;
//							} else {
//								$PublicFun.err("copyonerow", "表格复制失败：复制目标表格变量不存在 name:" + tr);
//								return -1;
//							}
//
//						} else {
//							$PublicFun.err("copyonerow", "表格复制失败：复制源表格变量不存在 name:" + sr);
//							return -1;
//						}
//					} else {
//						$PublicFun.err("copyonerow", "表格复制失败：复制行为NULL");
//						return -1;
//					}
//				} else {
//					$PublicFun.err("copyonerow", "表格复制失败：复制目标表格变量为NULL");
//					return -1;
//				}
//			} else {
//				$PublicFun.err("copyonerow", "表格复制失败：复制源表格变量为NULL");
//				return -1;
//			}
//		},
//		deleteonerow : function(sr, row) {
//			console.error('deleteonerow已废弃，请使用Grid.deleteRow');
//			if (sr) {
//				if (row != undefined) {
//					row = $PublicFun.stringToInt(row) - 1;
//					if (row < 0) {
//						$PublicFun.err("Delete One Row", "错误的行号，行号必须大于0 现在行号：" + (row + 1));
//						return -1;
//					}
//					var mSr = this.getOneVarStruct(sr.toLowerCase());
//					if (mSr) {
//						if (mSr.VT != 4) {
//							$PublicFun.err("Delete One Row", "源对象必须是表格变量");
//							return -1;
//						}
//						var mSourceData = $PublicFun.getSystemValue(this, mSr.pM, mSr.pS, mSr.VT);
//						if (mSourceData instanceof Array) {
//							if (mSourceData.length > row) {
//								mSourceData.splice(row, 1);
//								return 1;
//							} else {
//								$PublicFun.err("Delete One Row", "删除行号超过源对象记录数");
//								return -1;
//							}
//						} else {
//							$PublicFun.err("Delete One Row", "源对象为空");
//							return -1;
//						}
//					} else {
//						$PublicFun.err("Delete One Row", "表格删除失败：复制源表格变量不存在 name:" + sr);
//						return -1;
//					}
//				} else {
//					$PublicFun.err("Delete One Row", "表格删除失败：删除行为NULL");
//					return -1;
//				}
//			} else {
//				$PublicFun.err("copyonerow", "表格复制失败：复制源表格变量为NULL");
//				return -1;
//			}
//		},
//		appendonerow : function() {
//			console.error('appendonerow函数已废弃， 请使用Grid.appendRow');
//			if (arguments.length < 2) {
//				$PublicFun.err("append one row", "传入参数错误");
//				return -1;
//			}
//			var sr = arguments[0];
//			if (sr) {
//				var mSr = this.getOneVarStruct(sr.trim().toLowerCase());
//				if (mSr) {
//					if (mSr.VT != 4) {
//						$PublicFun.err("append one row", "源对象必须是表格变量");
//						return -1;
//					}
//					var length = arguments.length;
//					var rowData = [];
//					for (var i = 1; i < length; i++) {
//						rowData.push(arguments[i]);
//					}
//					var mSourceData = $PublicFun.getSystemValue(this, mSr.pM, mSr.pS, mSr.VT);
//					if (mSourceData instanceof Array) {
//						mSourceData.push(rowData);
//					} else {
//						mSourceData = $PublicFun.setSystemVar(this, mSr, []);
//						mSourceData.push(rowData);
//					}
//					return 1;
//				} else {
//					$PublicFun.err("append one row", "表格添加行失败：源表格变量不存在 name:" + sr);
//					return -1;
//				}
//			} else {
//				$PublicFun.err("append one row", "表格添加行失败：源表格变量为NULL");
//				return -1;
//			}
//		},
//		updateonerow : function() {
//			console.error('updateonerow已废弃，请使用Grid.updateRow');
//			if (arguments.length < 3) {
//				$PublicFun.err("update one row", "传入参数错误");
//				return -1;
//			}
//			var sr = arguments[0];
//			var row = $PublicFun.stringToInt(arguments[1]);
//			row = $PublicFun.stringToInt(row) - 1;
//			if (row < 0) {
//				$PublicFun.err("Delete One Row", "错误的行号，行号必须大于0 现在行号：" + (row + 1));
//				return -1;
//			}
//			if (sr) {
//				var mSr = this.getOneVarStruct(sr.toLowerCase());
//				if (mSr) {
//					if (mSr.VT != 4) {
//						$PublicFun.err("update one row", "源对象必须是表格变量");
//						return -1;
//					}
//					var mSourceData = $PublicFun.getSystemValue(this, mSr.pM, mSr.pS, mSr.VT);
//					if (mSourceData instanceof Array) {
//					} else {
//						mSourceData = $PublicFun.setSystemVar(this, mSr, []);
//					}
//					if (mSourceData.length > row) {
//						var length = arguments.length;
//						var rowData = mSourceData[row];
//						for (var i = 2; i < length; i++) {
//							if (arguments[i] != null) {
//								if (arguments[i] != "EMPTY") {
//									rowData[i - 2] = arguments[i];
//								}
//							}
//						}
//						return 1;
//					}
//				} else {
//					$PublicFun.err("update one row", "表格更新行失败：源表格变量不存在 name:" + sr);
//					return -1;
//				}
//			} else {
//				$PublicFun.err("update one row", "表格更新行失败：源表格变量为NULL");
//				return -1;
//			}
//		},
//		setgridonecolnumtofix : function(tr, index) {
//			console.error('setgridonecolnumtofix已废弃，请使用Grid.fixColumn');
//			index = $PublicFun.stringToInt(index) - 1;
//			if (index < 0) {
//				$PublicFun.err("setgridonecolnumtofix", "列号必须大于0，现在列号为：" + (index + 1));
//				return -1;
//			}
//			if (tr) {
//				var mTr = this.getOneVarStruct(tr.toLowerCase());
//				if (mTr) {
//					if (mTr.VT != 4) {
//						$PublicFun.err("setgridonecolnumtofix", "源对象必须是表格变量");
//						return -1;
//					}
//					var mSourceData = $PublicFun.getSystemValue(this, mTr.pM, mTr.pS, mTr.VT);
//					if (mSourceData instanceof Array) {
//						var lLen = mSourceData.length;
//						for (var i = 0; i < lLen; i++) {
//							mSourceData[i][index] = $PublicFun.numToFixStr(mSourceData[i][index]);
//						}
//						return 1;
//					} else {
//						$PublicFun.err("setgridonecolnumtofix", "源对象为空");
//						return -1;
//					}
//
//				} else {
//					$PublicFun.err("setgridonecolnumtofix", "表格更新行失败：源表格变量不存在 name:" + sr);
//					return -1;
//				}
//			} else {
//				$PublicFun.err("setgridonecolnumtofix", "表格更新行失败：源表格变量为NULL");
//				return -1;
//			}
//		},
//		batchupdategrid : function(tr, index, value) { // index 从1开始
//			console.error('batchupdategrid已废弃，请使用Grid.batchUpdate');
//			index = $PublicFun.stringToInt(index) - 1;
//			if (index < 0) {
//				$PublicFun.err("batchupdategrid", "列号必须大于0，现在列号为：" + (index + 1));
//				return -1;
//			}
//			if (tr) {
//				var mTr = this.getOneVarStruct(tr.toLowerCase());
//				if (mTr) {
//					if (mTr.VT != 4) {
//						$PublicFun.err("update One Col", "源对象必须是表格变量");
//						return -1;
//					}
//					var mSourceData = $PublicFun.getSystemValue(this, mTr.pM, mTr.pS, mTr.VT);
//					if (mSourceData instanceof Array) {
//						var lLen = mSourceData.length;
//						for (var i = 0; i < lLen; i++) {
//							mSourceData[i][index] = value;
//						}
//						return 1;
//					} else {
//						$PublicFun.err("update One Col", "源对象为空");
//						return -1;
//					}
//
//				} else {
//					$PublicFun.err("update one col", "表格更新行失败：源表格变量不存在 name:" + sr);
//					return -1;
//				}
//			} else {
//				$PublicFun.err("update one Col", "表格更新行失败：源表格变量为NULL");
//				return -1;
//			}
//		},
//		getonecell : function(sr, r, c) {
//			console.error('getonecell已废弃，请使用Grid.getCell');
//			if (sr) {
//				r = $PublicFun.stringToInt(r) - 1;
//				c = $PublicFun.stringToInt(c) - 1;
//				if (r < 0) {
//					$PublicFun.err("get one cell value", "行号必须大于0 ,现在行号为：" + (r + 1));
//					return "";
//				}
//				if (c < 0) {
//					$PublicFun.err("get one cell value", "列号必须大于0 ,现在列号为：" + (c + 1));
//					return "";
//				}
//				var mSr = this.getOneVarStruct(sr.toLowerCase());
//				if (mSr) {
//					if (mSr.VT != 4) {
//						$PublicFun.err("get one cell value", "源对象必须是表格变量");
//						return "";
//					}
//					var mSourceData = $PublicFun.getSystemValue(this, mSr.pM, mSr.pS, mSr.VT);
//					if (mSourceData instanceof Array) {
//						var mT = mSourceData[r][c];
//						if (mT) {
//							return mT;
//						} else {
//							return "";
//						}
//					} else {
//						return ""
//					}
//				} else {
//					$PublicFun.err("get one cell value", "表格获取值失败：源表格变量不存在 name:" + sr);
//					return "";
//				}
//			} else {
//				$PublicFun.err("get one cell value", "表格获取值失败：源表格变量为NULL");
//				return "";
//			}
//		},
//		setonecell : function(sr, r, c, v) {
//			console.error('setonecell已废弃，请使用Grid.setCell');
//			r = $PublicFun.stringToInt(r) - 1;
//			c = $PublicFun.stringToInt(c) - 1;
//			if (r < 0) {
//				$PublicFun.err("set one cell value", "行号必须大于0 ,现在行号为：" + (r + 1));
//				return -1;
//			}
//			if (c < 0) {
//				$PublicFun.err("set one cell value", "列号必须大于0 ,现在列号为：" + (c + 1));
//				return -1;
//			}
//			if (sr) {
//				var mSr = this.getOneVarStruct(sr.toLowerCase());
//				if (mSr) {
//					if (mSr.VT != 4) {
//						$PublicFun.err("set one cell value", "源对象必须是表格变量");
//						return -1;
//					}
//					var mSourceData = $PublicFun.getSystemValue(this, mSr.pM, mSr.pS, mSr.VT);
//					if (mSourceData instanceof Array) {
//						mSourceData[r][c] = v;
//					} else {
//						$PublicFun.err("set one cell value", "表格设值失败：表格为空不能设置");
//						return -1
//					}
//				} else {
//					$PublicFun.err("set one cell value", "表格获取值失败：源表格变量不存在 name:" + sr);
//					return -1;
//				}
//			} else {
//				$PublicFun.err("set one cell value", "表格获取值失败：源表格变量为NULL");
//				return -1;
//			}
//		},
//		initgrid : function(sr) {
//			console.error('initgrid已废弃，请使用Grid.init');
//			if (sr) {
//				var mSr = this.getOneVarStruct(sr.toLowerCase());
//				if (mSr) {
//					$PublicFun.setSystemVar(this, mSr, []);
//					return 1;
//				} else {
//					$PublicFun.err("init one grid", "表格初始化失败：源表格变量不存在 name:" + sr);
//					return -1;
//				}
//			} else {
//				$PublicFun.err("init one grid", "表格初始化失败：源表格变量为NULL");
//				return -1;
//			}
//		},
//		getgridrows : function(propertyName) {
//			console.error('getgridrows已废弃，请使用Grid.length');
//			if (propertyName) {
//				var property = this.getOneVarStruct(propertyName.toLowerCase());
//				if (property) {
//					var data = $PublicFun.getSystemValue(this, property.pM, property.pS, property.VT);
//					if (data instanceof Array) {
//						return data.length;
//					} else {
//						$PublicFun.err("getgridrows", "变量不是合法的数组 :" + propertyName);
//						return -1;
//					}
//				} else {
//					$PublicFun.err("getgridrows", "变量不存在 :" + propertyName);
//					return -1;
//				}
//			} else {
//				$PublicFun.err("getgridrows", "不合法的变量名");
//				return -1;
//			}
//		},
//		jsontogrid : function(jsonStr) {
//			console.error('jsontogrid已废弃，请使用Grid.fromJson');
//			try {
//				return JSON.parse(jsonStr);
//			} catch (e) {
//				$PublicFun.err("jsontogrid", "JSON 数据异常错误 ", e);
//				console.log(jsonStr)
//				return [];
//			}
//		},
//		gridtojson : function(pName) {
//			console.log('gridtojson已废弃，请使用Grid.toJson');
//			if (pName) {
//				pName = pName.toLowerCase();
//				var mOne = this.getOneVarStruct(pName);
//				if (mOne) {
//					var mTmpValue = $PublicFun.getSystemValue(this, mOne.pM, mOne.pS, mOne.VT);
//					if (mTmpValue) {
//						return JSON.stringify(mTmpValue);
//					} else {
//						return "";
//					}
//				} else {
//					$PublicFun.err("gridtojson", "变量不存在：" + pName)
//					return "";
//				}
//			} else {
//				$PublicFun.err("gridtojson", "变量为空");
//				return "";
//			}
//		},
//		gridcolcheck : function(id, colId, value) {
//			console.error('gridcolcheck已废弃，请使用Grid.batchUpdate');
//			if (value == 1)
//				value = true;
//			GridUtils.scopeCheck(this, id, colId, value);
//			return 1;
//		},
//		gridcolwidth : function(id, colId, value) {
//			console.error('gridcolwidth已废弃，请使用Grid.cellWidth');
//			GridUtils.cellWidth(this, id, colId, vlaue);
//		},
//		gridcolorder : function(id, orders) {
//			console.error('gridcolorder已废弃，请使用Grid.cellsOrder');
//			GridUtils.cellsOrder(this, id, orders);
//		},
//		gridnextrow : function(gridCtlId) {
//			console.error('gridnextrow已废弃，请使用Grid.nextRow');
//			GridUtils.nextRow(this, gridCtlId);
//		},
//		gridprevrow : function(gridCtlId) {
//			console.error('gridprevrow已废弃，请使用Grid.prevRow');
//			GridUtils.prevRow(this, gridCtlId);
//		},
//		gridgotorow : function(gridCtlId, rowId) {
//			console.error('gridgotorow已废弃，请使用Grid.jumpRow');
//			GridUtils.jumpRow(this, gridCtlId, rowId);
//		},
//		gridrowup : function(gridCtlId, row) {
//			console.error('gridrowup已废弃，请使用Grid.rowMoveUp');
//			GridUtils.rowMoveUp(this, gridCtlId, row);
//		},
//		gridrowdown : function(gridCtlId, row) {
//			console.error('gridrowdown已废弃，请使用Grid.rowMoveDown');
//			GridUtils.rowMoveDown(this, gridCtlId, row);
//		},
//		gridscrollup : function(gridCtlId, second) {
//			console.error('gridscrollup已废弃，请使用Grid.scrollUp');
//			GridUtils.scrollUp(this, gridCtlId, second);
//		},
//		gridscrolldown : function(gridCtlId, second) {
//			console.error('gridscrolldown已废弃，请使用Grid.scrollDown');
//			GridUtils.scrollDown(this, gridCtlId, second);
//		},
//
//		rollingbuild : function(name, data) {
//			console.error('rollingbuild已废弃，请使用Roll.build');
//			return this.Roll.build(name, data);
//		},
//		rollinghasnext : function(name) {
//			console.error('rollinghasnext已废弃，请使用Roll.hasNext');
//			return this.Roll.hasNext(name);
//		},
//		rollinggetone : function(name) {
//			console.error('rollinggetone已废弃，请使用Roll.next');
//			return this.Roll.next(name);
//		},


		gridtojson : function(propertyName) {
			return this.Grid.toJson(propertyName);
		},
		jsontogrid : function(propertyName) {
			return this.Grid.fromJson(propertyName);
		},
		
		// Fixed by Kevin.MOU
		/**
		 * 将某个浮动层绑定在目标控件上
		 * 
		 * @param ctl
		 *            {string | object} 目标控件ID或者控件对象
		 * @param layerCtl
		 *            {string} 浮动层控件ID
		 */
		driftLayer : function(ctl, layerId) {
			if (layerId == undefined) {
				layerId = ctl;
				ctl = this.R.CTRL;
			}
			CtlUtils.driftLayer(this.$runtime, ctl, layerId);
		},
		driftlayer : function(ctl, layerId) {
			this.driftLayer(ctl, layerId);
		},

		/**
		 * 对控件内容进行过滤
		 * 
		 * @param providerCtl
		 *            {string | object} 提供过滤关键词的控件ID或者控件对象
		 * @param filterCtl
		 *            {string} 进行内容过滤的控件ID
		 */
		ctlFilter : function(providerCtl, filterCtl) {
			CtlUtils.filter(this.$runtime, providerCtl, filterCtl);
		},

		/**
		 * 对控件内容进行搜索
		 * 
		 * @param providerCtl
		 *            {string | object} 提供过滤关键词的控件ID或者控件对象
		 * @param searchCtl
		 *            {string} 进行内容搜索的控件ID
		 */
		ctlSearch : function(providerCtl, searchCtl) {
			CtlUtils.filter(this.$runtime, providerCtl, searchCtl);
		},

		/**
		 * 获取某个控件对象
		 * 
		 * @param ctlId
		 *            {string} 控件ID
		 * @return {object}
		 */
		getCtl : function(ctlId) {
			return this.ctl(ctlId)
		},
		
		ctl : function(ctlId) {
			var ctl = this.$runtime.ctls[ctlId];
			if (!ctl)
				return $F.err('SandBox - ctl', '控件不存在于当前环境：' + ctlId), null;
			return ctl;
		},

		getctl : function(ctlId) {
			return this.ctl(ctlId);
		},

		/**
		 * 设置某个控件对象的风格
		 * 
		 * @param ctl
		 *            {string | object} 目标控件ID或者控件对象
		 * @param cssStyle
		 *            {object} 风格描述，参加jquery.dom.css
		 * @return {integer}
		 */
		setCtlStyle : function(ctl, cssStyle) {
			if ($.type(ctl) == 'string') {
				ctl = this.getCtl(ctl);
			}
			if (ctl) {
				if ($.isFunction(ctl.setStyle))
					ctl.setStyle(cssStyle);
			}
		},
		setctlstyle : function(ctl, cssStyle) {
			return this.setCtlStyle(ctl, cssStyle);
		},

		/**
		 * 调用组件的某个命令
		 * @method fireComponentCmd
		 * @param cmdId {string} 命令号
		 * @param [path] {string} 组件在页面中的path，为空时代表执行该实例下所有组件的cmdId命令
		 * @param [quitely] {boolean} 是否以安静模式运行（即时别名不存在也不会报出异常）
		 */
		fireComponentCmd : function(cmdId, path, silent) {
			CtlUtils.fireComponentCmd(this.$runtime, cmdId, path, this.R, silent);
		},
		firecpcmd : function(cmdId, path) {
			this.fireComponentCmd(cmdId, path);
		},

		/**
		 * 触发一个组件的事件
		 * 
		 * @param cti {string | object} 控件ID或对象
		 * @param e {string} 事件名称
		 */
		fireCtl : function(ctl, e) {
			CtlUtils.fireCtl(this.$runtime, ctl, e || 'change');
		},
		firectl : function(ctl) {
			this.fireCtl(ctl);
		},

		/**
		 * 注册一个变量监听器
		 * 
		 * @param propertyName
		 *            {string} 变量名
		 * @param cmdId
		 *            {string} 命令号
		 * @return {int}
		 */
		propertyListener : function(propertyName, cmdId) {
			return CmdUtils.propertyListener(this.$runtime, propertyName, cmdId);
		},
		propertylistener : function(propertyName, cmdId) {
			this.propertyListener(propertyName, cmdId);
			return true;
		},

		/**
		 * 跳转到下一页
		 * 
		 * @return {boolean}
		 */
		nextStep : function() {
			window.$D.nextStep(this.$runtime);
		},
		nextstep : function() {
			return nextStep();
		},

		/**
		 * 跳转到下一页
		 * 
		 * @return {boolean}
		 */
		prevStep : function() {
			window.$D.prevStep(this.$runtime);
		},
		prevstep : function() {
			return prevStep();
		},
		

		setcmdcaption : function(ctlId, caption) {
			var mTmp = this.$runtime.ctls[ctlId];
			if (mTmp.type) {
				if (mTmp.type == "BUTTON") {
					mTmp.dom[0].innerText = caption;
					return 1;
				} else {
					$PublicFun.log("set command caption", "非按钮控件");
					return -1;
				}
			} else {
				$PublicFun.log("set command caption", "非按钮控件");
				return -1;
			}

		},
		getcmdcaption : function(ctlId) {
			var mTmp = this.$runtime.ctls[ctlId];
			if (mTmp.type) {
				if (mTmp.type == "BUTTON") {
					return mTmp.dom[0].innerText;
				} else {
					$PublicFun.log("get command caption", "非按钮控件");
					return "";
				}
			} else {
				$PublicFun.log("get command caption", "非按钮控件");
				return "";
			}
		},
		/**
		 * 直接设置某个控件的值（该方法不触发绑定的值改变）
		 * 
		 * @param ctl
		 *            {object|string} 控件对象或者ID
		 * @param value
		 *            {any} 值
		 * @param [type]
		 *            {integer} 可为空或者1，为空时代表值为普通值，为1时代表值为二维数组（用于表格）
		 * @return {integer}
		 */
		setCtlValue : function(ctl, value, type) {
			if ($.type(ctl) == 'string')
				ctl = this.getCtl(ctl);
			if (ctl) {
				ctl.evt({
					type : (type || 0),
					data : value
				})
			}
		},

		closeWindow : function(e) {
			this.$instance.closeWindow(e);
		},
		minWindow : function() {
			this.$instance.minWindow();
		},
		maxWindow : function() {
			this.$instance.maxWindow();
		},
		/**
		 * 关闭当前实例所在的虚拟窗口。如果当前实例并非在虚拟窗口中打开，则命令无效
		 * 
		 * @param [e]
		 *            {boolean} 关闭窗口方式。 0或者无值： 正常关闭窗口，执行页面-240命令和父页面回调命令 1: 直接关闭窗口，不执页面-240命令，也不执行父页面回调命令
		 */
		closewindow : function(e) {
			this.closeWindow(e);
		},
		/**
		 * 最小化当前实例所在的虚拟窗口。如果当前实例并非在虚拟窗口中打开，则命令无效
		 */
		minwindow : function() {
			this.minWindow();
		},
		/**
		 * 最大化当前实例所在的虚拟窗口。如果当前实例并非在虚拟窗口中打开，则命令无效
		 */
		maxwindow : function() {
			this.maxWindow();
		},

		/**
		 * 进行一个日志记录
		 * 
		 * @param e
		 *            {string} 日志消息
		 * @param obj
		 *            {any} 在控制台上进行的对象输出
		 */
		log : function() {
			var args = ['Cmd - log'].concat(Array.prototype.splice.call(arguments, 0))
			$F.log.apply(this, args);
		},

		/**
		 * 进行一个日志记录
		 * 
		 * @param e
		 *            {string} 日志消息
		 * @param obj
		 *            {any} 在控制台上进行的对象输出
		 */
		out : function() {
			if (!$E.debug)
				return;
			
			var args = [ '%c[DEBUG]', 'color:#FF0000' ].concat(Array.prototype.splice.call(arguments, 0));
			console.log.apply(console, args)
		},


		/**
		 * 弹出一个消息框，使用蓝色提示图标
		 * 
		 * @param e {string} 消息内容
		 * @param callback {string|function} 回调命令组ID或者回调方法
		 * @param [state] integer 类型, 0=msg, 1=info, 2=warn, 3=alert
		 */
		msg : function(e, callback, state) {
			var a = this, runtime = a.$runtime;
			if ($.isFunction(callback)) {
				$F.msg(e, callback, state);
			} else {
				if (callback) {
					$F.msg(e, function() {
						a.doCommand(callback);			
					}, state)
				} else
					$F.msg(e, false, state)
			}
		},

		/**
		 * 弹出一个提示框，使用绿色提示图标
		 * 
		 * @param e {string} 消息内容
		 * @param callback {string|function} 回调命令组ID或者回调方法
		 */
		info : function(e, callback) {
			this.msg(e, callback, 1);
		},

		/**
		 * 弹出一个警示框，使用橙色提示图标
		 * 
		 * @param e {string} 消息内容
		 * @param callback {string|function} 回调命令组ID或者回调方法
		 */
		warn : function(e, callback) {
			this.msg(e, callback, 2);
		},

		/**
		 * 弹出一个错误框，使用红色提示图标
		 * 
		 * @param e {string} 消息内容
		 * @param callback {string|function} 回调命令组ID或者回调方法
		 */
		alert : function(e, callback) {
			this.msg(e, callback, 3);
		},

		/**
		 * 弹出一个询问框
		 * 
		 * @param e
		 *            {string} 询问内容
		 * @param submit
		 *            {callback | string} 确定回调方法或者命令号
		 * @param cancel
		 *            {callback | string} 取消回调方法或者命令号
		 */
		confirm : function(e, submit, cancel) {
			var a = this, submitCallback = submit, cancelCallback = cancel;
			if (! $.isFunction(submitCallback)) {
				submitCallback = function() {
					if (submit) {
						a.R.RESULT = 1;
						a.doCommand(submit);
					}
				}
			}
			if (! $.isFunction(cancelCallback)) {
				cancelCallback = function() {
					if (cancel) {
						a.R.RESULT = -1;
						a.doCommand(cancel);
					}
				}
			}
			$F.confirm(e, submitCallback, cancelCallback);
		},
		econfirm : function(e, submit, cancel) {
			this.confirm(e, submit, cancel);
		},

		/**
		 * 向实例环境写入一个数据，用于同页面内数据交互
		 * @method setInstanceItem
		 * @param name {string} 数据名
		 * @param item {any} 数据对象
		 */
		setInstanceItem : function(name, item) {
			this.$runtime.instance.setAttribute(name, item);
		},

		/**
		 * 从实例环境读取一个数据
		 * @method getInstanceItem
		 * @param name {string} 数据名
		 * @return {any} 数据对象
		 */
		getInstanceItem : function(name) {
			return this.$runtime.instance.getAttribute(name);
		},

		/**
		 * 向项目环境写入一个数据，用于跨页面数据交互
		 * @method setProjectItem
		 * @param name {string} 数据名
		 * @param item {any} 数据对象
		 */
		setProjectItem : function(name, item) {
			this.$runtime.project.setAttribute(name, item);
		},

		/**
		 * 从项目环境读取一个数据
		 * @method getProjectItem
		 * @param name {string} 数据名
		 * @return {any} 数据对象
		 */
		getProjectItem : function(name) {
			return this.$runtime.project.getAttribute(name);
		},

		/**
		 * 向NGS全局环境写入一个数据，用于框架核心数据交互
		 * @method setGlobalItem
		 * @param name {string} 数据名
		 * @param item {any} 数据对象
		 */
		setGlobalItem : function(name, item) {
			this.setpublicinfo(name, item);
		},
		setpublicinfo : function(key, Value) {
			$DynFun.setPublicVar(key, Value);
		},

		/**
		 * 从NGS全局环境读取一个数据
		 * @method getGlobalItem
		 * @param name {string} 数据名
		 * @return {any} 数据对象
		 */
		getGlobalItem : function(name) {
			return getpublicinfo(name);
		},
		getpublicinfo : function(key) {
			return $DynFun.getPublicValue(key);
		},

		/**
		 * 置入一个定时任务
		 * 
		 * @method putTask
		 * @param name
		 *            {string} 定时器名称
		 * @param delay
		 *            {integer} 延时执行毫秒
		 * @param immediate
		 *            {boolean} 是否立即执行
		 * @param cmdId
		 *            {string} 任务回调的命令组ID
		 * @param [ev]
		 *            {any} 任务执行入参环境, JSON格式对象
		 * @return {boolean}
		 */
		putTask : function(name, delay, immediate, cmdId, ev) {
			return this.$instance.putTask(this.$runtime, name, delay, immediate, cmdId, ev);
		},
		puttask : function(name, delay, immediate, cmdId, ev) {
			return this.putTask(name, delay, immediate, cmdId, ev);
		},

		/**
		 * 清除一个定时器任务
		 * 
		 * @method clearTask
		 * @param name
		 *            {string} 定时器名称
		 */
		clearTask : function(name) {
			return this.$runtime.instance.clearTask(name);
		},
		cleartask : function(name) {
			return this.clearTask(name);
		},
		
		/**
		 * 给控件绑定一个显隐状态变量
		 * @method bindState
		 * @example:
		 * 			bindState('var.xxx', 6) 绑定var.xxx到当前控件显隐状态，显示值为6
		 * 		or
		 * 			bindState('c2', 'var.xxx', 6) 绑定var.xxx到c2控件显隐状态，显示值为6
		 * 		or
		 * 			bindState('var.xxx', function(data){
		 * 				if (data > 5)
		 * 					return true;
		 * 				else
		 * 					return false;
		 * 			})
		 * @param ctl {string | object} 控件对象或者控件ID
		 * @param propertyName {string} 变量名
		 * @param value {any | function} 显示状态匹配值，当变量值和value相等时，该控件显示，否则隐藏。value可为具体值或者回调方法
		 * @return {boolean}
		 */
		bindState : function(ctl, propertyName, value) {
			if (arguments.length < 3) {
				value = propertyName;
				propertyName = ctl;
				ctl = this.R.CTRL;
			} else {
				if ($.type(ctl) == 'string')
					ctl = this.getCtl(ctl);
			}
			if (ctl) {
				ctl.state(this.$instance.getValue(propertyName, this.$runtime) == value ? 0 : 1);
				return this.$instance.bindValue(propertyName, ctl, function(e){
					if ($.isFunction(value))
						ctl.state(value(e.data) ? 0 : 1);
					else
						ctl.state(e.data == value ? 0 : 1);
				});
			} else
				return false;
		},
		
		require : function(js, callback) {
			var $this = this;
			require(['js/amds/' + js + $E.jsv], function(o) {
				callback.call($this, o)
			})
		},
		
		effects : function(method) {
			if (! method)
				return $F.err('Cmd - effects', '没有指定特效的方法名'), false;

			try {
				var args = [].slice.call(arguments, 1);
				require(['js/amds/effects' + $E.jsv], function(Effects) {
					return Effects[method].apply(Effects, args);
				})
			}catch(e) {
				$F.err('Cmd - effects', e);
			}
		},
		
		workStatus : function(status) {
			this.$project.events.notify($CONST.ModuleEvent.ECM_WORKSTART, {workStatus: status})
		},
		
		/**
		 * 获取电话随路数据
		 * @param key {string} 随路数据KEY
		 * @param cmdId {string|callback} 回调的命令号，或者回调方法
		 */
		callAttach : function(key, cmdId) {
			var a = this;
			a.$softphone.attachData(key, function(data){
				if ($.isFunction(cmdId)) {
					cmdId(data);
				} else {
					a.$instance.doCmd('P' + cmdId, {
						RESULT: data
					}, a.$runtime);
				}
			})
		},
		
		/**
         * 异步处理事务方法，系统将在屏幕中进行忙碌状态提示
         * @method process
         * @param cmdId {string} 处理事务的回调命令
         * @param [message] {string} 处理时提示的消息内容
         */
		process : function(cmdId, message) {
			var a = this;
			$F.process(function(){
				a.doCommand(cmdId);
			}, message || '处理中')
		},
		
		refreshJobs : function() {
			this.$project.refreshJobsPromptly();
		},
		
		stop : function(e) {
			throw new StopException(e || 'Stop script running')
			//return 'STOP-RUN-NEXT-COMMAND'
		},
		
		/**
		 * 根据工单ID获取短链接代码
		 * @method getWoShortCode
		 * @param woid {string} 工单GUID
		 * @return {string} 短链接代码
		 */
		getWoShortCode : function(woid) {
			var url = '/m/nl?q=sp&at=wo&ai=' + woid;
			if (window.$E.dataService.key !== 'default')
				url += '&ds=' + window.$E.dataService.key;
			return this.getShortCode(url);
		},
		

		/**
		 * 获取一个无登录的短链接代码
		 * @method getNlShortCode
		 * @param at {string} 链接打开的页面类型，包括obj=市场活动，dyn=无会话动态页面
		 * @param ai {string} 管理类型的ID，at=obj时为objectivetypeid，at=dyn时为动态页面
		 * @param [cid] {string} 当前客户的GUID
		 *  [params...] {any} 其他入参数据，在动态页面加载中，可以通过R.paremeters获得。根据入参顺序，依次为f1, f2, f3...
		 * @return {string} 短链接代码
		 */
		getNlShortCode : function(at, ai, cid) {
			var url = '/m/nl?q=sp&at=' + at + '&ai=' + ai;
			if (cid)
				url += '&cid=' + cid;
			if (arguments.length > 3) {
				for(var i=3; i<arguments.length; i++) {
					url += '&f' + (i-2) + '=' + arguments[i];
				}
			}
			if (window.$E.dataService.key !== 'default')
				url += '&ds=' + window.$E.dataService.key;
			return this.getShortCode(url);
		},
		
		/**
		 * 根据URL获取短链接代码
		 * @method getShortCode
		 * @param url {string} URL地址
		 * @return {string} 短链接代码
		 */
		getShortCode : function(url) {
			if (! url) {
				$F.err('SandBox - getShortUri', '无效的URL');
				return {
					CODE : -1,
					MESSAGE : '无效的URL'
				};
			}
			
			var su = {};
			Ajax.post({
				url : $E.url + '/S',
				data : url,
				async: false,
				success: function(data) {
					su = {
						CODE: data.code,
						MESSAGE: data.message,
						VALUE: data.value
					};
				},
				fail: function(jqXHR, textStatus, errorThrown) {
					su = {
						CODE: -1,
						MESSAGE: '[' + jqXHR.status + '] ' + errorThrown
					}
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					su = {
						CODE : -1,
						MESSAGE : '[' + textStatus + '] ' + errorThrown
					}
				}
			})
			return su;
		},
		
		/**
		 * 获取请求短链接的URL地址
		 * @method getShortUrl
		 * @param shortCode {string} 短链接代码
		 * @return {String} 请求短链接的URL地址
		 */
		getShortUrl : function(shortCode) {
			return $E.host + $E.url + '/T?' + shortCode;
		},
		
		/**
		 * 运行一张报表
		 * @param rptId {string} 报表GUID
		 * @param params {object} 入参
		 */
		runReport : function(rptId, params) {
			window.$E.openPlugin('报表', this.$project, 'reporter', 'R#' + rptId, params);
		},
		
		ldap : function(url) {
			$F.process(function(){
				$.ajax({
					type: 'post',
					data: url
				}).done(function(data){
					if (data.code > 0)
						window.open(data.code);
					else
						$F.alert(data.message);
				}).fail(function(jXHR, status, err) {
					$F.alert(status);
				})
			})
		},
		
		/**
		 * 隐藏或显示当前页面的“返回”按钮
		 * 本方法仅适用于移动终端模式多页面模式
		 * @method hideNavBtn
		 * @param state {boolean} 显示状态，true=显示，false=不显示
		 */
		hideNavBtn : function(state) {
			console.info('Set nav buttons state: ' + (state? true : false))
			$instance.hideNavBtn = state;
			window.$E.showNavBtn(this.$instance.hideNavBtn);
		},
		
		abbr : function(propertyName, length) {
			var property = this.$instance.getProperty(propertyName, this.$runtime);
			if (! property)
				return $F.err('Cmd - abbr', '变量不存在: ' + propertyName), '';
			if (property.VT != 3)
				return $F.err('Cmd - abbr', '变量不是字符串类型：' + propertyName), '';
			
			var data = this.$instance.getValue(propertyName, this.$runtime, '');
			return data.replace('\n', '').abbr(length);
		},
		
		stackStyles : function(styles) {
			this.$instance.runtime.container.css(styles)
		},
		
		/**
		 * 对图片验证码进行验证
		 * @param proeprtyName {string} 用于验证短信的变量名
		 * @return {boolean}
		 */
		verify : function(propertyName) {
			var property = this.$instance.getProperty(propertyName, this.$runtime);
			if (! property)
				return $F.err('Cmd - verify', '变量不存在: ' + propertyName), false;
			if (property.VT != 3)
				return $F.err('Cmd - verify', '变量不是字符串类型：' + propertyName), false;
			
			var v = false;
			Ajax.post({
				url : $E.url + '/verify_',
				data : {
					code: this.$instance.getValue(propertyName, this.$runtime, ''),
				},
				async: false,
				success : function(data) {
					if (data.code > 0)
						v = true;
				}
			})
			return v;
		},
		
		/**
		 * 发送短信验证码
		 * @method smsCodeSend
		 * @param ecsid {string} 短信验证的类型
		 * @param type {integer} 0=向当前客户发送短信（仅适用于NL模式），1=向当前staff发送短信，2=向指定手机发送短信
		 * @param mobile {string} 接收短信的手机号码（仅当type=2时有效）
		 * @return {object}
		 */
		smsCodeSend : function(ecsid, type, mobile) {
			var v = {
				code: -1,
				message: '请求异常'
			};
			Ajax.post({
				url : $E.url + '/smsCodeSend_',
				data : {
					uid: $E.uid,
					ecsid: ecsid,
					type: type,
					mobile: (mobile || '')
				},
				async: false,
				success : function(data) {
					v = data;
				}
			})
			return v;
		},
		
		/**
		 * 执行一个外挂加载的插件方法
		 * @method cabinet
		 * @param jsName {string} 插件js文件名（不含后缀），文件位于js/amds目录下
		 * @param method {string} 执行插件的方法
		 */
		cabinet : function(jsName, method) {
			var a = this;
			try {
				var args = [].slice.call(arguments, 2);
				args.push(a.R)
				require(['js/amds/' + jsName + '.js'], function(amdObject) {
					var cmdId = amdObject[method].apply(amdObject, args);
					if ($.type(cmdId) == 'string')
						a.doCommand(cmdId)
				})
			}catch(e) {
				$F.err('Cmd - cabinet', e);
			}
		},
		
		/**
		 * 在当前实例中创建一个内置方法（实例内有效）
		 * @param name 方法名
		 * @param callback 方法实体
		 */
		storeMethod : function(name, callback) {
			if (! this.$instance.methods)
				this.$instance.methods = {};
			this.$instance.methods[name] = callback;
			return 1;
		},
		
		/**
		 * 执行某个已创建的内置方法
		 * @param name {string} 方法名
		 * @param arguments {...} 入参
		 * @return {any} 执行结果
		 */
		doMethod : function(name) {
			try {
				var args = [].slice.call(arguments, 1);
				return this.$instance.methods[name].apply($this, args);
			} catch(e) {
				$F.err('Cmd - doMethod', e);
				return '';
			}
		},
		
		/**
		 * 注册一个键盘监听事件
		 * @param key {string} 键盘监听代码
		 * @param cmdId {string} 执行监听的命令ID
		 */
		hotkey : function(key, cmdId) {
			var a = this;
			$E.registerHotkey(a.$instance, key, function(e){
				var cmdList = a.$dynCmds["P" + cmdId];
				if (cmdList)
					doOneCmdList(a, "Command-P" + cmdId, cmdList);
			})
		},
		
		/**
		 * 转ivr
		 * @param mute 是否是直接转
		 * @param number 转接号码
		 * @param sData 随路数据
		 * @param cmdId 回调命令组id
		 */
		transferToIVR : function(mute, number, sData, cmdId) {
			if (this.$softphone) {
				this.$softphone.ivr.transferToIVR(mute, number, sData, this.$runtime, cmdId);
			}
		}

	};
 
    window.$DynFun = {
    		getServerPara : function(sandbox, OneCmd, mapList,sqlKey) {
    			// Circle_
    			var mReturnMap = this.getSubServerPara(sandbox, OneCmd, mapList);
    			if (sandbox.$X != 0) {
    				var circleObj = sandbox.R["CURRENTROW"];
    				if (circleObj instanceof Array) {
    					var iCount = circleObj.length;
    					for (var i = 0; i < iCount; i++) {
    						var mTmp = i + 1;
    						mReturnMap["Circle_" + mTmp] = circleObj[i];
    					}
    				}
    			}
    			var mStrName, mValue;
    			var RelInfo = OneCmd.RL;
    			if (RelInfo != undefined) {
    				var iCount = RelInfo.length;
	    			for (var i = 0; i < iCount; i++) {
	    				var mOne = RelInfo[i];
	    				// console.log(mOne);
	    				switch (mOne.PF) {
	    				case 2:// 局部变量
	    					if (mOne.AN) {
	    						mStrName = mOne.PN;
	    						mValue = this.getLocateValue(sandbox, mStrName);
	    						mReturnMap[mOne.AN] = mValue;
	    					}
	    					break;
	    				case 0: // 属性变量
	    					if (mOne.AN) {
	    						var mOneVar = sandbox.getOneVarStruct(mOne.PN);
	    						var mValue;
	    						if (mOneVar == undefined) {
	    							mValue = "";
	    						} else {
	    							mValue = this.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
	    						}
	    						mReturnMap[mOne.AN] = mValue;
	    					}
	    					break;
	    				case 1: // 静态全局值替换
	    					if (mOne.AN) {
	    						mStrName = mOne.PN;
	    						mValue = this.getSystemStatic(sandbox, mStrName);
	    						mReturnMap[mOne.AN] = mValue;
	    					}
	    					break;
	    				case 3: // 两个固定的变量替换
	    					if (mOne.AN) {
	    						if (StringUtil.trim(mOne.PN).toUpperCase() == "SYS.OBJECTIVEID") {
	    							mReturnMap[mOne.AN] = sandbox.$instance.id;
	    						} else if (StringUtil.trim(mOne.PN).toUpperCase() == "SYS.GUID") {
	    							mReturnMap[mOne.AN] = $PublicFun.newGuid();
	    						}
	    					}
	    				}
	    			}
    			}
    			if (sqlKey){
    				var mOutSql=$PublicFun.getOneSqlKey(sqlKey);
    				if (mOutSql){
    					mReturnMap["#OUT"]=mOutSql;
    				}
    			}
    			return mReturnMap;
    		},
    		getSubServerPara : function(sandbox, OneCmd, mapList) {
				var mReturnMap;
				if (mapList) {
					mReturnMap = mapList;
				} else {
					mReturnMap = {};
				}
				if (OneCmd.Sub != undefined) {
					var iCount = OneCmd.Sub.length;
					for (var i = 0; i < iCount; i++) {
						var mSubStr = OneCmd.Sub[i];
						var mFilter = sandbox.evalValue(this.replaceSubRelVar(sandbox, OneCmd.Sub[i], OneCmd.RL, i));
						mReturnMap["SUB_EP" + i] = mFilter;
					}
				}
				return mReturnMap;
			},
    		/**
    		 * @method replaceCalcContent
    		 * @description 获取计算公式正文值
    		 * @param RelList
    		 *            Express Flag
    		 */
    		replaceCalcContent : function(sandbox, oneCmd, Express, Flag) {
    			if (oneCmd.Sub != undefined) {
    				// console.log(oneCmd);
    				var iCount = oneCmd.Sub.length;
    				for (var i = 0; i < iCount; i++) {
    					// "#{"+(_CalcSubExpress.size()-1)+"}#"
    					var mSubStr = oneCmd.Sub[i];
    					var mFilter = sandbox.evalValue(this.replaceSubRelVar(sandbox, oneCmd.Sub[i], oneCmd.RL, i));
    					// console.log(mFilter);
    					var mTmpRegexp = new RegExp("#\\{" + i + "\\}#", "gi");
    					Express = Express.replace(mTmpRegexp, mFilter);
    				}
    			}
    			return this.replaceVarValue(sandbox, oneCmd.RL, Express, Flag).trim();
    		},

    		replaceCircleV :function(sandbox, Express) {
    			var iB = Express.indexOf("[");
    			var CircleObj = sandbox.R["CURRENTROW"];
    			if (CircleObj) {
    				while (iB > -1) {
    					var iE = Express.indexOf("]");
    					if (iE > -1) {
    						var mNum = Express.substring(iB + 1, iE).trim();
    						if (isNaN(mNum)) {
    							iB = Express.indexOf("[", iB + 1);
    						} else {
    							var mTmpValue = CircleObj[mNum];
    							if (mTmpValue == undefined) {
    								mTmpValue = "";
    							}
    							Express = this.replaceStr(Express, "[" + mNum + "]", mTmpValue, 0);
    							iB = Express.indexOf("[", iB);
    						}
    					} else {
    						iB = -1;
    					}
    				}
    				return Express;
    			} else {
    				return Express;
    			}
    		},

    		/**
    		 * @method setLocateVar
    		 * @description 设置局部变量值
    		 * @param name
    		 *            属性名 值 属性值
    		 */
    		setLocateVar : function(sandbox, name, value) {
    			if (value == undefined) {
    				value = "";
    			}
    			if (name) {
    				name = name.toUpperCase();
    				this.setSubLocateValue(sandbox.R, name, value)
    			} else {
    				$PublicFun.err("setLocateVar", "局部变量名不能为空");
    			}
    		},

    		setSubLocateValue: function(ObjInfo, name, value) {
    			if (ObjInfo == undefined) {
    				return;
    			}
    			var iTmp = name.indexOf("-");
    			if (iTmp > 0) {
    				var mTmpStr = name.substring(0, iTmp).trim();
    				if (ObjInfo[mTmpStr] == undefined) {
    					ObjInfo[mTmpStr] = {};
    				}
    				this.setSubLocateValue(ObjInfo[mTmpStr], name.substring(iTmp + 1), value);
    			} else {
    				ObjInfo[name] = value;
    			}
    		},
    		/**
    		 * @method refreshObjCell
    		 * @description 用于设置表格行列更新
    		 */
    		refreshObjCell : function(RefreshObj, pId, R, C, v) {
    			if (RefreshObj[pId]) {
    				if (RefreshObj[pId].type == 0) {
    					return;
    				} else {
    					var data = RefreshObj.data;
    					if (data) {
    						var k;
    						if (C) {
    							k = R + "," + C;
    						} else {
    							k = R;
    						}
    						data[k] = v;
    					} else {
    						if (C) {
    							var data1 = {};
    							data1[R + "," + C] = v;
    							RefreshObj[pId] = {
    								type : 1,
    								data : data1
    							};
    						} else {
    							var data1 = {};
    							data1[R] = v;
    							RefreshObj[pId] = {
    								type : 1,
    								data : data1
    							};
    						}
    					}
    				}
    			} else {
    				if (C) {
    					var data1 = {};
    					data1[R + "," + C] = v;
    					RefreshObj[pId] = {
    						type : 1,
    						data : data1
    					};
    				} else {
    					var data1 = {};
    					data1[R] = v;
    					RefreshObj[pId] = {
    						type : 1,
    						data : data1
    					};
    				}
    			}
    		},	
		/**
		 * @method getSystemValue  
		 * @description 获取值
		 * @param pM
		 *            前缀 pS 后缀
		 */
		getSystemValue : function(sandbox, pM, pS, pT) {
			var mTmp;
			if (pM == "var" || pM == 'tabc') {
				mTmp = sandbox.$locData[pM];
			} else {
				mTmp = sandbox.$pubData[pM];
			}
			if (mTmp == undefined) {
				switch (pT) {
				case 3: // 'VT-CHR
					return "";
				case 1: // 'VT-INT
					return 0;
				case 2: // 'VT-DAT
					return '1900-01-01';
				case 4: // '表格型
					return "";
				case 5: // 整型
					return 0;
				case 6://对象型
					return undefined;
				default: // 'VT-CHR
					return "";
				}
			}
			mTmp = mTmp[pS];
			if (mTmp == undefined) {
				switch (pT) {
				case 3: // 'VT-CHR
					return "";
				case 1: // 'VT-INT
					return 0;
				case 2: // 'VT-DAT
					return '1900-01-01';
				case 4: // '表格型
					return "";
				case 5: // 整型
					return 0;
				case 6: //对象型
					return undefined;
				default: // 'VT-CHR
					return "";
				}
			} else {
				return mTmp;
			}
		},

		/**
		 * @method setSystemVar 命令是固定脚本都要用到
		 * @description 设置系统变量值跟据ID
		 * @param pM
		 *            属性名 pS 值 属性值
		 */
		setSystemVar : function(sandbox, oneVar, value) {
			if (value == undefined) {
				value = "";
			}
			var pM = oneVar.pM, pS = oneVar.pS, mData;
			if (pM == "var" || pM == 'tabc') {
				if (sandbox.$locData == undefined) {
					$PublicFun.err("sandbox.locValue", "sandbox.locData is Null")
					return "";
				}
				mData = sandbox.$locData;
			} else {
				if (sandbox.$pubData == undefined) {
					$PublicFun.err("sandbox.Data", "sandbox.pubData is Null")
					return "";
				}
				mData = sandbox.$pubData;
				if (oneVar.PType != 0) {
					if (pS.startWith('cust_')) {
						sandbox.$instance.syncSystemObject(pM + "." + pS, value);
					} else if (pS.startWith('obj_')) {
						sandbox.$instance.syncSystemObject(pM + "." + pS, value);
					}
				}
			}
			if (mData[pM] == undefined) {
				mData[pM] = {};
			}
			// console.log(oneVar);
			// console.log(oneVar.VT)ValueType;
			switch (oneVar.VT) {
			case 3: // 'VT-CHR
				value = value.toString();
				mData[pM][pS] = value;
				return value;
			case 1: // 'VT-INT
				if (value == true) {
					value = 1;
				} else {
					value = $PublicFun.stringToFloat(value);
				}
				mData[pM][pS] = value;
				return value;
			case 2: // 'VT-DAT
				mData[pM][pS] = value;
				return value;
			case 4: // '表格型
				mData[pM][pS] = value;
				return value;
			case 5: // 整型
				if (value == true) {
					value = 1;
				} else {
					value = $PublicFun.stringToInt(value);
				}
				mData[pM][pS] = value;
				return value;
			case 6://对象型
				mData[pM][pS] = value;
				return value;
			default: // 'VT-CHR
				value = value.toString();
				mData[pM][pS] = value;
				return value;
			}
		},
		/**
		 * @method getPublicValue
		 * @description 获取值
		 * @param name
		 */
		getPublicValue : function(name) {
			if (window.$Z == undefined) {
				return "";
			}
			// console.log(name);
			if (name) {
				name = name.toLowerCase();
				var mTmp = window.$Z[name];
				if (mTmp == undefined) {
					return "";
				} else {
				//	delete window.$Z[name];
					return mTmp;
				}
			} else {
				return "";
			}
		},
		/**
		 * @method setPublicVar
		 * @description 设置全局变量值
		 * @param name
		 *            属性名 值 属性值
		 */
		setPublicVar : function(name, value) {
			if (window.$Z == undefined) {
				window.$Z = {};
			}
			name = name.toLowerCase();
			window.$Z[name] = value;
			// console.log(name+":"+value);
		},
		/**
		 * 刷新对象 命令是固定脚本都要用到
		 */
		refreshObjNew : function(v) {
			return {
				type : 0,
				data : v
			};
		},

		getObjData : function(sandbox, name) {
			if (name) {
				return sandbox.$instance.objective.getValue(name);
			} else {
				$PublicFun.log("getObjData", "Objective字段名为空")
				return "";
			}
		},

		setCustInfo : function(sandbox, name, value) {
			if (name) {
				var instance = sandbox.$instance;
				if (instance) {
					var data = instance.customer;
					if (data) {
						data.setValue(name, value);
						return 1;
					} else {
						$PublicFun.err("setCustomerInfo", "客户资料对象不存在");
						return "";
					}
				} else {
					$PublicFun.err("setCustomerInfo", "instance对象不存在");
					return "";
				}
			} else {
				$PublicFun.err("setCustomerInfo", "客户字段名为空");
				return "";
			}
		},

		getCustInfo : function(sandbox, name) {
			if (name) {
				// name=name.toLowerCase();
				var instance = sandbox.$instance;
				if (instance) {
					var data = instance.customer;
					if (data) {
						return data.getValue(name)
					} else {
						$PublicFun.err("getCustomerInfo", "客户资料对象不存在");
						return "";
					}
				} else {
					$PublicFun.err("getCustomerInfo", "instance对象不存在");
					return "";
				}
			} else {
				$PublicFun.err("getCustomerInfo", "客户字段名为空");
				return "";
			}
		},
		/**
		 * @method getLocateValue
		 * @description 获取值
		 * @param name
		 */
		getLocateValue: function(sandbox, name) {
			if (name) {
				name = name.toUpperCase();
				return this.getSubLocateValue(sandbox.R, name);
			} else {
				return "";
			}

		},

		getSubLocateValue : function(ObjInfo, name) {
			if (ObjInfo == undefined) {
				return "";
			}
			var iTmp = name.indexOf("-");
			if (iTmp > 0) {
				var mTmpStr = name.substring(0, iTmp).trim();
				if (ObjInfo[mTmpStr] == undefined  || ObjInfo[mTmpStr] ==null) {
					return "";
				} else {
					return this.getSubLocateValue(ObjInfo[mTmpStr], name.substring(iTmp + 1));
				}
			} else {
				var mTmp = ObjInfo[name];
				if (mTmp == undefined || mTmp==null) {
					return "";
				} else {
					return mTmp;
				}
			}
		},

		getSystemStatic: function(sandbox, name) {
			if (name) {
				name = name.toUpperCase();
				var mReturn;
				try {
					if (name == "EPID") {
						mReturn = $E.staff.epid;
					} else if (name == "EPIDTB") {
						mReturn = $E.staff.epidSql;
					} else if (name == "STAFFID") {
						mReturn = $E.staff.id;
					} else if (name == "STAFFNAME") {
						mReturn = $E.staff.name;
					} else if (name == "AGENTID") {
						mReturn = $E.staff.agentId;
					} else if (name == "G_ISSUPER") {
						var isSupervisor = parseInt(sandbox.$project.getParam('ISSUPE', 2));
						mReturn = ($E.staff.supervisor > isSupervisor) ? 1 : 0;
					} else if (name == "G_SFASHA") {
						mReturn = parseInt(sandbox.$project.getParam('SFASHA', 0));
					} else if (name == "ROLEGROUPID") {
						mReturn = sandbox.$instance.project.groupId;
					} else if (name == "ROLEGROUPNAME") {
						mReturn = sandbox.$instance.project.groupName;
					} else if (name == "ANI") {
						if (sandbox.$instance.project.cwInfo && sandbox.$instance.project.cwInfo.callInfo && sandbox.$instance.project.cwInfo.callInfo.getValue) {
							mReturn = sandbox.$instance.project.cwInfo.callInfo.getValue("ani");
						} else {
							mReturn = '';
						}
					} else if (name == "DNIS") {
						if (sandbox.$instance.project.cwInfo && sandbox.$instance.project.cwInfo.callInfo && sandbox.$instance.project.cwInfo.callInfo.getValue) {
							mReturn = sandbox.$instance.project.cwInfo.callInfo.getValue("dnis");
						} else {
							mReturn = '';
						}
					} else if (name == "CALLTYPE") {
						if (sandbox.$instance.project.cwInfo) {
							mReturn = sandbox.$instance.project.cwInfo.callType;
						} else {
							mReturn = '';
						}
					} else if (name == "EXTENSION") {
						if (sandbox.$instance.project.cwInfo && sandbox.$instance.project.cwInfo.callInfo && sandbox.$instance.project.cwInfo.callInfo.getValue) {
							mReturn = sandbox.$instance.project.cwInfo.callInfo.getValue("extension");
						} else {
							mReturn = '';
						}
					} else if (name == "CUREVENTID") {
						if (sandbox.$instance.project.cwInfo) {
							mReturn = sandbox.$instance.project.cwInfo.eventGuid;
						} else {
							mReturn = '';
						}
					} else if (name.startWith("OBJ_")) {
						name = name.substring(4);
						mReturn = this.getObjData(sandbox, name);
					} else if (name.startWith("CUST_")) {
						name = name.substring(5);
						mReturn = this.getCustInfo(sandbox, name);
					} else {
						mReturn = "";
					}
					if ($F.isNull(mReturn)) {
						return "";
					} else {
						return mReturn;
					}
				} catch (e) {
					$PublicFun.err("Cmd - getSystemStatic", "Get [" + name + "] failed", e);
					return "";
				}

			} else {
				return "";
			}
		},
		/**
		 * @method replaceFindProperty
		 * @description 获取值
		 * @param RunTime
		 *            Express
		 */
		replacePropertyVarName : function(sandbox, Express) {
			var iB = Express.indexOf("[");
			while (iB > -1) {
				var iE = Express.indexOf("]", iB);
				if (iE > -1) {
					var mPropertyName = Express.substring(iB + 1, iE).trim();
					var mOneVar = sandbox.getOneVarStruct(mPropertyName.toLowerCase());
					if (mOneVar == undefined) {
						iB = iE;
					} else {
						var mValue = this.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
						Express = this.replaceStr(Express, "[" + mPropertyName + "]", mValue, 0);
						iB = Express.indexOf("[", iB);
					}
				} else {
					iB = -1;
				}
			}
			return Express;
		},
		replaceStr:function(Source, Replace, To, Flag) {
			if (Flag == undefined || Flag == 0) {
				Source = Source.replace2(Replace, To);
			} else if (Flag == 1) {
				Source = Source.replace2("#" + Replace + "#", To);
				Source = Source.replace2(Replace, To);
			} else if (Flag == 2) {
				Source = Source.replace2("@" + Replace + "@", To);
				Source = Source.replace2(Replace, To);
			} else {
				Source = Source.replace2("#" + Replace + "#", To);
				Source = Source.replace2("@" + Replace + "@", To);
				Source = Source.replace2(Replace, To);
			}
			return Source;
		},
		/**
		 * ReplaceSub 替换子方法
		 */
		replaceSubRelVar:function(sandbox, Express, RelList, SubIndex) {
			// { PId : "F2FE54D7-7AD2-CC4B-B4F0-8CA87514C8A0",PFlag : 1, OtherName : "STAFFID",RelFlag : 0,SubList :[],RpFlag : 0,AsName : "C6",},
			var iCount = RelList.length;
			for (var i = 0; i < iCount; i++) {
				var mTmp = RelList[i];
				var mSubList = mTmp.SubList;
				var mSubLen = mSubList.length;
				for (var j = 0; j < mSubLen; j++) {
					if (mSubList[i] == SubIndex) {
						switch (mTmp.PF) {
						case 0:
							var mOneVar = sandbox.getOneVarStruct(mTmp.PN);
							if (mOneVar == undefined) {
								$PublicFun.err("replaceSubRelVar", "未找到对应变量：" + mTmp.PN + " Express:" + Express);
							} else {
								var mValue = this.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
								Express = this.replaceStr(Express, "[" + mTmp.PN + "]", mValue, mTmp.RP);
							}
							break;
						case 1:
							var mValue = this.getSystemStatic(sandbox, mTmp.PN);
							Express = this.replaceStr(Express, "[" + mTmp.PN + "]", mValue, mTmp.RP);
							break;
						case 2:
							var mValue = this.getLocateValue(sandbox, mTmp.PN);
							Express = this.replaceStr(Express, "[" + mTmp.PN + "]", mValue, mTmp.RP);
							break;
						default:
							// console.log(mTmp);
							var mOneVar = sandbox.getOneVarStruct(mTmp.PN);

							if (mOneVar == undefined) {
								$PublicFun.err("replaceSubRelVar", "未找到对应变量：" + mTmp.PN + " Express:" + Express);
							} else {
								var mValue = this.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
								Express = this.replaceStr(Express, "[" + mTmp.PN + "]", mValue, mTmp.RP);
							}
							break;
						}
						break; // break For
					}
				}
			}
			return Express;
		},
		

		replaceVarValue:function(sandbox, RelList, Express, Flag) {
			// { PId : "F2FE54D7-7AD2-CC4B-B4F0-8CA87514C8A0",PFlag : 1, OtherName : "STAFFID",RelFlag : 0,SubList :[],RpFlag : 0,AsName : "C6",},
			var o = Express;
			if (RelList != undefined) {
				var iCount = RelList.length;
				for (var i = 0; i < iCount; i++) {
					var mTmp = RelList[i];
					// console.log(RelList);
					if (mTmp.RL == Flag || mTmp.RL == 2) {
						switch (mTmp.PF) {
						case 0:
							var mOneVar = sandbox.getOneVarStruct(mTmp.PN);
							if (mOneVar == undefined) {
								$PublicFun.err("replaceVarValue", "变量未定义:" + mTmp.PN);
							} else {
								var mValue = this.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
								Express = this.replaceStr(Express, "[" + mTmp.PN + "]", mValue, mTmp.RP);
							}
							break;
						case 1:
							var mValue = this.getSystemStatic(sandbox, mTmp.PN);
							// console.log(mValue);
							Express = this.replaceStr(Express, "[" + mTmp.PN + "]", mValue, mTmp.RP);
							break;
						case 2:
							var mValue;
							if (mTmp.PN.startWith('g_'))
								mValue = this.getSystemStatic(sandbox, mTmp.PN);
							else
								mValue = this.getLocateValue(sandbox, mTmp.PN);
							Express = this.replaceStr(Express, "[" + mTmp.PN + "]", mValue, mTmp.RP);
							break;
						default:
							// console.log(mTmp);
							var mOneVar = sandbox.getOneVarStruct(mTmp.PN);
							if (mOneVar == undefined) {
								$PublicFun.err("replaceVarValue", "变量未定义:" + mTmp.PN);
							} else {
								var mValue = this.getSystemValue(sandbox, mOneVar.pM, mOneVar.pS, mOneVar.VT);
								Express = this.replaceStr(Express, "[" + mTmp.PN + "]", mValue, mTmp.RP);
							}
							break;
						}
					}
				}
			}
			if (sandbox.$X == 2) {// 命令中循环
				Express = this.replaceCircleV(sandbox, Express);
			}
			if (o !== Express)
				$PublicFun.log("Replace To",Express);
			return Express;
		}
		
    }

	/*
	 * 全局函数部分。。。
	 */
	var $PublicFun = {
		round : function(v, dec) {
			dec = dec || 0;
			if (dec > 0) {
				var mTmp = 10 * dec;
				return Math.round(v * mTmp) / mTmp
			} else if (dec < 0) {
				var mTmp = 10 * Math.abs(dec)
				return Math.round(v / mTmp) * mTmp
			} else {
				return Math.round(v);
			}
		},
		getMD5 : function(sandbox, md5Str) {
			var mRs = $F.ajaxSync("JSGenerateServlet", {
				token : sandbox.$token,
				dbPool : "",
				clsName : "elite.sysfun.root.FunctionFF",
				func : "md5",
				source : md5Str
			}, sandbox.$digest)
			if (mRs.code < 0) {
				return "";
			} else {
				return mRs.message;
			}
		},
		getDecodeDes : function(sandbox, source, key) {
			var mRs = $F.ajaxSync("JSGenerateServlet", {
				token : sandbox.$token,
				dbPool : "",
				clsName : "elite.sysfun.root.FunctionFF",
				func : "decodedes",
				source : source,
				keyStr : key
			}, sandbox.$digest)
			if (mRs.code < 0) {
				return "";
			} else {
				return mRs.message;
			}
		},
		getEncodeDes : function(sandbox, source, key) {
			var mRs = $F.ajaxSync("JSGenerateServlet", {
				token : sandbox.$token,
				dbPool : "",
				clsName : "elite.sysfun.root.FunctionFF",
				func : "des",
				source : source,
				keyStr : key
			}, sandbox.$digest)
			if (mRs.code < 0) {
				return "";
			} else {
				return mRs.message;
			}
		},

		mergeArray : function(mainArray, mainKey, subArray, subKey, toIndex) {
			if (mainArray instanceof Array) {
				if (subArray instanceof Array) {
					var mIndexMap = {};
					var iCount = mainArray.length;
					for (var i = 0; i < iCount; i++) {
						mIndexMap[mainArray[i][mainKey]] = i;
					}
					iCount = subArray.length;
					var mKey, mTmpKey, mSubGridObj;
					for (var i = 0; i < iCount; i++) {
						mTmpKey = subArray[i][subKey];
						if (mKey == mTmpKey && mKey != undefined) {
							mSubGridObj[mSubGridObj.length] = subArray[i]
						} else {
							var mOneRow = mIndexMap[mTmpKey]
							if (mOneRow >= 0) {
								mKey = mTmpKey;
								var mRowD = mainArray[mOneRow];
								if (mRowD[toIndex] instanceof Array) {
									mSubGridObj = mRowD[toIndex];
								} else {
									mRowD[toIndex] = [];
									mSubGridObj = mRowD[toIndex];
								}
								mSubGridObj[mSubGridObj.length] = subArray[i];
							}
						}
					}
					mIndexMap = {};
					return 1;
				} else {
					$PublicFun.err("mergeArray", "子数据源为空");
					return 0;
				}
			} else {
				$PublicFun.err("mergeArray", "主数据源为空");
				return 0;
			}
		},
		toTransArraySubReturn:function(fixCols){
			var mtmp=[],one=[];
			var iTmp, iTmpCount = fixCols.length || 0;
			for (iTmp = 0; iTmp < iTmpCount; iTmp++) {
				one.push('');
			}
			mtmp.push(one);
			return mtmp;
		},
		toTransArray : function(sourceArray, fixCols, transCol, dataCol) {
			if (sourceArray instanceof Array) {
				var i, iCount = sourceArray.length || 0;
				if (iCount > 0) {
					var j, jCount = sourceArray[0].length || 0;
					var iTmp, iTmpCount = fixCols.length || 0;
					if (iTmpCount <= 0) {
						this.err("transArray", "未定义固定列数据");
						return [];
					} else {
						for (iTmp = 0; iTmp < iTmpCount; iTmp++) {
							fixCols[iTmp] = $PublicFun.stringToInt(fixCols[iTmp]) - 1;
							if (fixCols[iTmp] >= jCount) {
								this.err("transArray", "定义固定列数据错误，超出数据源列号，定义列号为：" + (fixCols[iTmp] + 1) + " 数据源总列数为：" + jCount);
								return this.toTransArraySubReturn(fixCols);
							}
						}
					}
					transCol = $PublicFun.stringToInt(transCol) - 1;
					if (transCol >= jCount || transCol < 0) {
						this.err("transArray", "交叉列数据定义错误，交叉列为：" + transCol + " 数据源总列数为：" + jCount);
						return this.toTransArraySubReturn(fixCols);
					}
					dataCol = $PublicFun.stringToInt(dataCol) - 1;
					if (dataCol >= jCount || dataCol < 0) {
						this.err("transArray", "数据列数据定义错误，数据列为：" + dataCol + " 数据源总列数为：" + jCount);
						return this.toTransArraySubReturn(fixCols);
					}
					var mAllTransCols = {};
					var mAllTransRows = {};
					var mLastData = [];
					mLastData[0] = [];
					var iRowMax = 1, iColMax = iTmpCount;
					for (i = 0; i < iCount; i++) {
						var mOneRow = sourceArray[i];
						var mTmpRowKey = "";
						for (iTmp = 0; iTmp < iTmpCount; iTmp++) {
							mTmpRowKey += "-" + mOneRow[fixCols[iTmp]];
						}
						var mCurRow = mAllTransCols[mTmpRowKey];
						if (mCurRow == undefined) {
							mCurRow = iRowMax;
							iRowMax++;
							mAllTransCols[mTmpRowKey] = mCurRow;
							mLastData[mCurRow] = [];
							for (iTmp = 0; iTmp < iTmpCount; iTmp++) {
								mLastData[mCurRow][iTmp] = mOneRow[fixCols[iTmp]];
							}
						}
						var mCurCol = mAllTransCols[mOneRow[transCol]];
						if (mCurCol == undefined) {
							mCurCol = iColMax;
							iColMax++;
							mAllTransCols[mOneRow[transCol]] = mCurCol;
							mLastData[0][mCurCol] = mOneRow[transCol];
						}
						mLastData[mCurRow][mCurCol] = mOneRow[dataCol];
					}
					return mLastData;
				} else {
					this.err("transArray", "数据源为空数组");
					return  this.toTransArraySubReturn(fixCols);
				}

			} else {
				this.err("transArray", "数据源非数组");
				return this.toTransArraySubReturn(fixCols);
			}
		},
		autoCallEnd : function(project, vShowFlag, vShowNext, customerGuid, eventComments) {
			vShowFlag = vShowFlag || 0;
			vShowNext = vShowNext || "";
			$PublicFun.log("autoCallEnd", "Do AutoEnd ShowFlag:" + vShowFlag + " ShowNext:" + vShowNext + " customerGuid: " + customerGuid + " eventComments:" + eventComments);
			var mObj = {
				showModule : vShowFlag,
				nextShow : vShowNext,
				customerGuid : customerGuid,
				eventComments: eventComments
			};
			try {
				project.events.notify($CONST.ModuleEvent.ECM_CALLSUMMARY, mObj);
			} catch (e) {
				$PublicFun.err("autoCallEnd", "Do AutoEnd Failed err:" + e + "  ShowFlag:" + vShowFlag + " ShowNext:" + vShowNext, e);
				return -1;
			}
			return 1;
		},
		getOneRowTableBound : function(tokenId, tableName, fieldKey, sqlKey, sqlParas, dbPool) {
			var mRs = $F.ajaxSync("JSGenerateServlet2", {
				token : sandbox.$token,
				dbPool : dbPool || "",
				name : "System.getBoundData.oneRow",
				sqls : [ {
					key : sqlKey,
					params : sqlParas
				} ]
			}, sandbox.$digest);
			if (mRs.code > 0) {
				var mRsInfo = mRs.value[0];
				var iCount = mRsInfo.length || 0;
				if (iCount <= 0) {
					this.err("getOneRowTableBound", "Load One BoundData Failed SqlId:" + sqlKey + " DBPool:" + dbPool);
					return null;
				} else {
					var mTmpReturn = new BoundData(tableName);
					mTmpReturn.KeyInfoEdit(fieldKey);
					for (var i = 0; i < iCount; i++) {
						var mOne = mRsInfo[i];
						mTmpReturn.OldValue(mOne.field, mOne.value, mOne.type);
					}
					return mTmpReturn;
				}
			}
		},
		fieldTypeStringToBoundType : function(sType) {
			// F_String:0 S,F_Float:1 N,F_Date:2 D,F_Boolean:3,F_Clob:4,F_Long:5,F_Int:6 I
			if (sType == "I") {
				return 6;
			} else if (sType == "N") {
				return 1;
			} else if (sType == "D") {
				return 2;
			} else {
				return 0;
			}
		},
		
		getPara : function(sandbox, paraName) {
			if (sandbox) {
				if (paraName == undefined) {
					this.log("getPara", "参数名为未定义");
					return "";
				} else {
					paraName = paraName.trim();
				}
				return sandbox.$instance.project.getParam(paraName)
			} else {
				this.log("getPara", "sandbox 对象不存在");
				return "";
			}

		},
		xmlEncdoe : function(text) {
			if (text == undefined || text == null) {
				return "";
			} else {
				text = text.replace2("&", "&amp;");
				text = text.replace2("<", "&lt;");
				text = text.replace2(">", "&gt;");
				text = text.replace2("\"", "&quot;");
				text = text.replace2("'", "&apos;");
				text = text.replace(/\x0D/g, "&#x000D;");
				return text;
			}
		},
		xmlDecode : function(text) {
			if (text == undefined || text == null) {
				return "";
			} else {
				text = text.replace2("&amp;", "&");
				text = text.replace2("&lt;", "<");
				text = text.replace2("&gt;", ">");
				text = text.replace2("&quot;", "\"");
				text = text.replace2("&apos;", "'");
				text = text.replace2("&#x000D;", "\n");
				return text;
			}
		},
		/*
		 * {Key:[{dynId:XXX,cmd:xxx,para:{c1:xx,c2:xxx....},....
		 * 		]
		 *  .....
		 * }
		 */
		addOneSqlKey:function(sqlKey,iIndex,sdynId,scmdId,opara){
			var mOne={dynId:sdynId,
					  cmd:scmdId,
					  para:opara
					};
			if (this.$SQL[sqlKey]){
			}else{
				this.$SQL[sqlKey]={};
			}
			if (this.$SQL[sqlKey]["o"+iIndex]){
			}else{
				this.$SQL[sqlKey]["o"+iIndex]=[];
			}
			this.$SQL[sqlKey]["o"+iIndex].push(mOne);
		},
		showOneSql:function(sqlKey){
			
			if (sqlKey==undefined){
				this.log("Sql Sub Info","Sub Sql List All Info", this.$SQL);
			}else {
				sqlKey=sqlKey.trim().toUpperCase();
				if (this.$SQL[sqlKey]){
					this.log("Sql Sub Info","Sub Sql List SqlKey:"+sqlKey, this.$SQL[sqlKey]);
				}else{
					this.log("Sql Sub Info", "not find sqlkey:"+sqlKey);
				}
			}
		},
		getOneSqlKey:function(sqlKey){
			if (sqlKey){
				sqlKey = sqlKey.trim().toUpperCase();
				if (this.$SQL[sqlKey]){
					return this.$SQL[sqlKey];
				}else{
					return undefined;
				}
			}
		},
		clearOneSqlKey:function(key,index){
			if (key==undefined){
				this.$SQL={};
				return 1;
			}
			key=key.trim().toUpperCase();
			if (index==undefined){
				if (this.$SQL[key]){
					// this.$SQL[key]={};
					delete this.$SQL[key];
					return 1;
				}else{
					return -1;
				}
			}else{
				if (this.$SQL[key]){
					if (this.$SQL[key]["o"+index]){
						// this.$SQL[key]["o"+index]=[];
						delete this.$SQL[key]["o"+index];
						return 1;
					}else{
						return -1;
					}
				}else{
					return -1;
				}
			}
		},
		$SQL:{},
		/**
		 * 工单使用
		 */
		$GI : {	wo : null },

		/**
		 * 进度条使用
		 */
		$PR : {
			UseFlag : 0,
			ProcessObj : '',
			MaxValue : 100,
			CurValue : 0
		},

		/**
		 * XML 操作使用
		 */
		$GX : {	xmlProcess : null },

		/**
		 * JSON 操作使用
		 */
		$GJ : {JSONProcess : null },

		//TimeCacheKey : {},
		openWindowsNewOtherURL : function(url, title, parameters) {
			try {
				var winhwd = window.open(url, title, parameters);
				if(!winhwd){
					$F.err("确认弹出窗口是否被拦截");
				} else{
					winhwd.focus();
				}
				return 1;
			} catch (e) {
				this.err("openWindowsNewOtherURL", " Open IE Failed:" + e.message);
				return -1;
			}
		},
		now : function() {
			var mTime = $F.ajaxSync("GetDBTime", {});
			if (mTime) {
				if (mTime.code > 0) {
					return mTime.value;
				} else {
					$PublicFun.err("getDBTime", "获取时间失败 Result:" + mTime.code);
					return new Date().format('yyyy-MM-dd hh:mm:ss');
				}
			} else {
				$PublicFun.err("getDBTime", "获取时间失败");
				return new Date().format('yyyy-MM-dd hh:mm:ss');
			}
		},
		getFileType : function(vStr) {
			var iIndex = vStr.lastIndexOf(".");
			if (iIndex > -1) {
				return vStr.substr(iIndex);
			} else {
				return "";
			}
		},
		 
		stringToArray : function(data, split) {
			data = data || '';
			if (split) {
			} else {
				this.log("stringToArray", "分解字符串失败，分隔符无效");
				return [];
			}
			var mResult = [];
			var mLen = split.length;
			var iTmp = data.indexOf(split);
			while (iTmp > -1) {
				mResult.push(data.substring(0, iTmp));
				data = data.substring(iTmp + mLen);
				iTmp = data.indexOf(split);
			}
			//if (data.trim()) {
				mResult.push(data);
			//}
			return mResult;
		},
		logGrp : function(c, e) {
			$F.logGroup('Cmd - ' + c, e);
		},
		logGrpEnd : function(c, e) {
			if (!e)
				$F.logGroupEnd();
			else
				$F.logGroupEnd('Cmd - ' + c, e);
		},
		log : function(c, e, o) {
			if (o == undefined) {
				if (e == undefined)
					$F.log('Cmd', c);
				else
					$F.log('Cmd - ' + c, e);
			} else
				$F.log('Cmd - ' + c, e, o);
		},
		err : function(c, e, o) {
			if (o == undefined) {
				if (e == undefined)
					$F.err('Cmd', c);
				else
					$F.err('Cmd - ' + c, e)
			} else
				$F.err('Cmd - ' + c, e, o);
		},
		stringSplitOne : function(src, split) {
			var ReturnObj = {};
			var iIndex = src.indexOf(split);
			if (iIndex > -1) {
				ReturnObj["F"] = 1;
				ReturnObj["V"] = src.substring(0, iIndex);
				ReturnObj["N"] = src.substring(iIndex + split.length);
			} else {
				ReturnObj["F"] = -1;
				ReturnObj["N"] = src;
			}
			return ReturnObj;
		},
		stringToInt : function(v) {
			try {
				v = parseInt(v);
				if (!isNaN(v)) {
					return v;
				} else {
					return 0;
				}
			} catch (e) {
				return 0;
			}
		},
		stringToFloat : function(v) {
			try {
				v = parseFloat(v);
				if (!isNaN(v)) {
					return v;
				} else {
					return 0;
				}
			} catch (e) {
				return 0;
			}
		},
		isDate : function(s) {
			if (s == null || s == undefined) {
				return false;
			}
			var reg = /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/;
			if (reg.test(s)) {
				return true;
			} else {
				if (s.length < 10) {
					return false;
				}
				if (reg.test(s.substring(0, 10))) {
					if (this.isTime(s.substring(10).trim())) {
						return true;
					} else {
						return false;
					}
				}
			}
			return false;
		},

		isTime : function(value) {
			try {
				value = value.trim();
				var mTmp;
				if (value.indexOf(":") > 0) {
					mTmp = value.split(":");
				} else {
					return false;
				}
				if (mTmp.length > 2) {
					if (mTmp[0].length < 3) {
						return true;
					}
				} else {
					return false;
				}
			} catch (e) {
				return false;
			}
			return false;
		},
		newGuid : function() {
			return Guid.raw();
		},
		 
		buildSameString : function(vChar, vNumTime) {
			var mTmp = "";
			for (var i = 0; i < vNumTime; i++) {
				mTmp += vChar;
			}
			return mTmp;
		},
		numToFixStr : function(vStr) {
			if (vStr == undefined) {
				return "";
			}
			if (vStr == "") {
				return "";
			}
			vStr = vStr.toString().toLowerCase();
			var mIndex = vStr.indexOf("e");
			if (mIndex > -1) {
				var mTmpS = vStr.substr(mIndex + 1).trim();
				var mTmpOneChar = mTmpS.substr(0, 1);
				var mNumStr = vStr.substr(0, mIndex).trim();
				var mDH = mNumStr.indexOf(".");
				var mTmpIndex;
				if (mTmpOneChar == "-") {
					var mTmpNum = this.stringToInt(mTmpS.substr(1));
					if (mDH == -1) {
						if (mNumStr.length > mTmpNum) {
							mTmpIndex = mNumStr.length - mTmpNum;
							return mNumStr.substr(0, mTmpIndex) + "." + mNumStr.substr(mTmpIndex);
						} else {
							mTmpIndex = mTmpNum - mNumStr.length;
							if (mTmpIndex == 0) {
								return "0." + mNumStr;
							} else {
								return "0." + this.buildSameString("0", mTmpIndex) + mNumStr;
							}
						}
					} else {
						if ((mDH - 1) > mTmpNum) {
							return mNumStr.substr(0, (mDH - mTmpNum)) + "." + mNumStr.substr(mDH - mTmpNum).replace2(".", "");
						} else {
							return "0." + this.buildSameString("0", mTmpNum - mDH) + mNumStr.substr(0, 1) + mNumStr.substr(2);
						}
					}
				} else if (mTmpOneChar == "+") {
					var mTmpNum1 = this.stringToInt(mTmpS.substr(1));
					if (mDH == -1) {
						return mNumStr + this.buildSameString("0", mTmpNum1);
					} else {
						if ((mNumStr.length - mDH - 1) >= mTmpNum1) {
							if ((mNumStr.length - mDH - 1) == mTmpNum1) {
								return mNumStr.replace2(".", "")
							} else {
								return mNumStr.substr(0, mDH + mTmpNum1 + 1).replace2(".", "") + "." + mNumStr.substr(mDH + mTmpNum1 + 1);
							}
						} else {
							return mNumStr.replace2(".", "") + this.buildSameString("0", mTmpNum1 - (mNumStr.length - mDH - 1));
						}
					}
				} else {
					var mTmpNum2 = this.stringToInt(mTmpS);
					if (mDH == -1) {
						return mNumStr + this.buildSameString("0", mTmpNum2);
					} else {
						if ((mNumStr.length - mDH - 1) >= mTmpNum2) {
							if ((mNumStr.length - mDH - 1) == mTmpNum2) {
								return mNumStr.replace2(".", "")
							} else {
								return mNumStr.substr(0, mDH + mTmpNum2 + 1).replace2(".", "") + "." + mNumStr.substr(mDH + mTmpNum2 + 1);
							}
						} else {
							return mNumStr.replace2(".", "") + this.buildSameString("0", mTmpNum2 - (mNumStr.length - mDH - 1));
						}
					}
				}

			} else {
				return vStr;
			}
		},
		getAgeFromIdCard : function(id) {
			if (id == undefined) {
				return -1;
			}
			if (id == "") {
				return -1;
			}
			var now = new Date();
			var year, month, day;
			if (id.length == 15) {
				year = 1900 + this.stringToInt(id.substr(6, 2));
				month = this.stringToInt(id.substr(8, 2)) - 1;
				day = this.stringToInt(id.substr(10, 2));
				if (now.getMonth() < month || (now.getMonth() == month && now.getDay() < day)) {
					return now.getFullYear() - year - 1;
				} else {
					return now.getFullYear() - year;
				}
			} else if (id.length == 18) {
				year = this.stringToInt(id.substr(6, 4));
				month = this.stringToInt(id.substr(10, 2)) - 1;
				day = this.stringToInt(id.substr(12, 2));
				if (now.getMonth() < month || (now.getMonth() == month && now.getDay() < day)) {
					return now.getFullYear() - year - 1;
				} else {
					return now.getFullYear() - year;
				}
			} else {
				this.log("getagefromidcard", "invalid id card for getagefromidcard");
				return -1;
			}
		},
		getBirthdayFromIdCard : function(id) {
			var d = new Date();
			var year, month, day;
			d.setHours(0, 0, 0, 0);
			if (id.length == 15) {
				year = 1900 + this.stringToInt(id.substr(6, 2));
				month = this.stringToInt(id.substr(8, 2)) - 1;
				day = this.stringToInt(id.substr(10, 2));
				d.setFullYear(year, month, day);
			} else if (id.length == 18) {
				year = this.stringToInt(id.substr(6, 4));
				month = this.stringToInt(id.substr(10, 2)) - 1;
				day = this.stringToInt(id.substr(12, 2));
				d.setFullYear(year, month, day);
			} else {
				this.log("getbirthdayfromidcard", "invalid id card for getbirthdayfromidcard");
				return "";
			}
			return d.format();
		},
		getGenderFromIdCard : function(id) {
			var gender = 0;
			if (id.length == 15) {
				gender = this.stringToInt(id.substr(14, 1));
			} else if (id.length == 18) {
				gender = this.stringToInt(id.substr(14, 3));
			} else {
				this.log("getgenderfromidcard", "invalid id card for getgenderfromidcard");
				return "";
			}
			return gender % 2;
		},
		isValidIdCard : function(id) {
			//-1 长度错误  -2 生日或输入内容错误 -3 身份证末位校验错误   1为正常返回
			var idcard = id.trim();
			if (idcard == "") {
				return -1; 
			}
			/* 身份号码位数及格式检验 */
			if (idcard.length == 15) {
				var regex2;
				if ((this.stringToInt(idcard.substr(6, 2)) + 1900) % 4 == 0 || ((this.stringToInt(idcard.substr(6, 2)) + 1900) % 100 == 0 && (this.stringToInt(idcard.substr(6, 2)) + 1900) % 4 == 0)) {
					regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;// 测试出生日期的合法性
				} else {
					regex2 = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;// 测试出生日期的合法性
				}
				if (regex2.test(idcard)) {
					return 1;
				} else {
					return -2;
				}
			} else if (idcard.length == 18) {
				var regex1 = /^[1-9][0-7]\d{4}((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229))\d{3}(\d|X|x)?$/;
				if (regex1.test(idcard)) {
					var S = (this.stringToInt(idcard.charAt(0)) + this.stringToInt(idcard.charAt(10))) * 7 + (this.stringToInt(idcard.charAt(1)) + this.stringToInt(idcard.charAt(11))) * 9 + (this.stringToInt(idcard.charAt(2)) + this.stringToInt(idcard.charAt(12))) * 10 + (this.stringToInt(idcard
							.charAt(3)) + this.stringToInt(idcard.charAt(13))) * 5 + (this.stringToInt(idcard.charAt(4)) + this.stringToInt(idcard.charAt(14))) * 8 + (this.stringToInt(idcard.charAt(5)) + this.stringToInt(idcard.charAt(15))) * 4 + (this.stringToInt(idcard.charAt(6)) + this
							.stringToInt(idcard.charAt(16))) * 2 + this.stringToInt(idcard.charAt(7)) * 1 + this.stringToInt(idcard.charAt(8)) * 6 + this.stringToInt(idcard.charAt(9)) * 3;
					var Y = S % 11;
					var M = "F";
					var JYM = "10X98765432";
					M = JYM.substr(Y, 1);
					/* 判断校验位 */
					if (M == idcard.charAt(17).toUpperCase()) {
						return 1;
					} else {
						return -3;
					}
				} else {
					return -2;
				}
			} else {
				return -1;
			}
		},
		playVoice : function(para) {
			var openWindows = window.open("", "_blank", "height=60, width=550,resizable=yes ,toolbar=no ,menubar=no");
			var insertStr = '<HTML><HEAD><TITLE>播放录音</TITLE><script id="clientEventHandlersJS" language="javascript"> 	function btn_onclick() {try{ player.Play();}catch(e){setTimeout(btn_onclick,500); } } btn_onclick();	</script> </HEAD><BODY><object id="player" height="64" width="100%" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"><PARAM NAME="Filename" VALUE="' + para + '"><param NAME="AutoStart" VALUE="0"><param NAME="Balance" VALUE="0"><param NAME="EnableContextMenu" VALUE="-1"><param NAME="url" VALUE=""><param NAME="PlayCount" VALUE="1"><param name="rate" value="1"><param name="currentPosition" value="0"><param name="currentMarker" value="0"><param name="defaultFrame" value=""><param name="invokeURLs" value="0"><param name="baseURL" value=""><param name="stretchToFit" value="0"><param name="volume" value="100"><param name="mute" value="0"><param name="uiMode" value="full"><param name="windowlessVideo" value="0"><param name="fullScreen" value="0"><param name="enableErrorDialogs" value="-1"><param name="SAMIStyle" value></object></BODY></HTML>';
			openWindows.document.write(insertStr);
		}
	};
    window.$PublicFun = $PublicFun;
    
    window.StopException = function(message) {
    	this.message = message;
    };
    StopException.prototype = {
    	toString: function() {
    		return this.message;
    	}
    };
    
})(jQuery);
